load method

Future<String?> load({
  1. SitumMapViewCallback? situmMapLoadCallback,
  2. SitumMapViewCallback? situmMapDidUpdateCallback,
  3. Map<String, dynamic>? creationParams,
})

Implementation

Future<String?> load({
  SitumMapViewCallback? situmMapLoadCallback,
  SitumMapViewCallback? situmMapDidUpdateCallback,
  Map<String, dynamic>? creationParams,
}) async {
  if (situmMapLoadCallback != null) {
    this.situmMapLoadCallback = situmMapLoadCallback;
  }
  if (situmMapDidUpdateCallback != null) {
    this.situmMapDidUpdateCallback = situmMapDidUpdateCallback;
  }

  print("Situm> Dart load() invoked.");
  if (defaultTargetPlatform == TargetPlatform.android) {
    // iOS will handle multiple load calls with presentInNewView().
    // Android will handle multiple load calls by returning immediately.
    // TODO: check iOS onDisposeCalled.
    if (situmMapLoading) {
      return "ALREADY_LOADING";
    }
    if (situmMapLoaded) {
      notifyLoadCallbacksIfNeeded();
      return "ALREADY_DONE";
    }
  }
  print("Situm> MethodChannel will be invoked.");
  situmMapLoading = true;
  final result =
      await methodChannel.invokeMethod<String>('load', creationParams);
  print("Situm> Got load result: $result");
  situmMapLoading = false;
  situmMapLoaded = true;
  notifyLoadCallbacks();
  return result;
}