start method

Future<bool> start({
  1. String? customID,
  2. EventHandlerAMapGeoFenceStatus? onGeoFenceChanged,
})

开启围栏状态监听 customID !=null 监听指定customID 的围栏 仅支持ios android 第一次 调用 开启广播监听

Implementation

Future<bool> start(
    {String? customID,
    EventHandlerAMapGeoFenceStatus? onGeoFenceChanged}) async {
  if (!_supportPlatform || !_isInitialize || _hasListener) return false;
  if (_isIOS) assert(customID != null, 'ios 平台 customID 必须不为null');
  final bool? state = await _channel.invokeMethod('startGeoFence', customID);
  if (state == true) {
    _hasListener = true;
    _channel.setMethodCallHandler((MethodCall call) async {
      switch (call.method) {
        case 'updateGeoFence':
          onGeoFenceChanged?.call(call.arguments == null
              ? null
              : AMapGeoFenceStatusModel.fromMap(
                  call.arguments as Map<dynamic, dynamic>));
      }
    });
  }
  return state == true;
}