General principles | Mobile SDK | Urbi Documentation
Flutter SDK

General principles

Some SDK methods (e.g., those that access a remote server) return deferred results Future or CancelableOperation in cases where it may be important to cancel the request. To process a deferred result, you can register two callback functions: completion and error.

For example, you can get information from object directory:

import 'package:dgis_mobile_sdk/dgis.dart' as sdk;

// Create an object for directory search
searchManager = sdk.SearchManager.createOnlineManager(context);

// Get the object by its identifier
searchManager.searchByDirectoryObjectId(objectId)

For more information on working with an object directory, see Object directory.

Some SDK objects provide data channels. To subscribe to a data channel, you need to create and specify a handler function. You can unsubscribe when data processing is no longer required. The Channel interface is used to work with value streams.

Subscribing to Channel returns StreamSubscription.

For example, you can subscribe to a visible rectangle channel, which is updated when the visible area of the map is changed:

import 'dart:async';

import 'package:dgis_mobile_sdk/dgis.dart' as sdk;

class SampleState extends State<Widget> {
  final mapWidgetController = sdk.MapWidgetController();
  late final StreamSubscription<sdk.GeoRect> visibleRectSubscription;

  @override
  void initState() {
    super.initState();
     mapWidgetController.getMapAsync((map) {
        visibleRectSubscription = map.camera.visibleRectChannel.listen((geoRect) {
          debugPrint("Current rect: ${geoRect}")
        });
      });
  }

  @override
  void dispose() {
    visibleRectSubscription.cancel();
    super.dispose();
  }
...
}