requestLocationWithReGeocode_completionBlock method

Future<bool?> requestLocationWithReGeocode_completionBlock(
  1. bool withReGeocode,
  2. void completionBlock(
    1. CLLocation? location,
    2. AMapLocationReGeocode? regeocode,
    3. NSError? error
    )
)

Implementation

Future<bool?> requestLocationWithReGeocode_completionBlock(bool withReGeocode, void Function(CLLocation? location, AMapLocationReGeocode? regeocode, NSError? error) completionBlock) async {
  // print log
  if (fluttifyLogEnabled) {
    debugPrint('fluttify-dart: AMapLocationManager@$refId::requestLocationWithReGeocode([\'withReGeocode\':$withReGeocode])');
  }

  // invoke native method
  final __result__ = await kAmapLocationFluttifyChannel.invokeMethod('AMapLocationManager::requestLocationWithReGeocode_completionBlock', {"withReGeocode": withReGeocode, "__this__": this});


  // handle native call
  MethodChannel('AMapLocatingCompletionBlock::Callback@$refId', kAmapLocationFluttifyMethodCodec)
      .setMethodCallHandler((methodCall) async {
        try {
          final args = methodCall.arguments as Map;
          switch (methodCall.method) {
            case 'AMapLocatingCompletionBlock__':
              // print log
              if (fluttifyLogEnabled) {
                debugPrint('fluttify-dart-callback: completionBlock([\'location\':${args['location']}, \'regeocode\':${args['regeocode']}, \'error\':${args['error']}])');
              }

              // handle the native call
              completionBlock(AmapLocationFluttifyIOSAs<CLLocation>(args['location']), AmapLocationFluttifyIOSAs<AMapLocationReGeocode>(args['regeocode']), AmapLocationFluttifyIOSAs<NSError>(args['error']));
              break;
            default:
              throw MissingPluginException('方法${methodCall.method}未实现');
              break;
          }
        } catch (e) {
          debugPrint(e.toString());
          rethrow;
        }
      });

  return __result__;
}