dispose method

Future<void> dispose()

释放对象, 如果AmapLocationDisposeMixin不能满足需求时再使用这个方法

Implementation

Future<void> dispose() async {
  await _locationController?.close();
  _locationController = null;

  await _geoFenceEventController?.close();
  _geoFenceEventController = null;

  // 取消注册广播
  if (Platform.isAndroid) {
    await kAmapLocationFluttifyChannel.invokeMethod(
        'com.amap.api.fence.GeoFenceClient::unregisterBroadcastReceiver');
  }

  await _androidClient?.onDestroy();
  await _androidClient?.release__();
  await _iosClient?.release__();

  final isCurrentPlugin = (Ref it) => it.tag__ == 'amap_location_fluttify';
  await gGlobalReleasePool.where(isCurrentPlugin).release_batch();
  gGlobalReleasePool.removeWhere(isCurrentPlugin);

  _androidClient = null;
  _iosClient = null;
}