Skip to content

Instantly share code, notes, and snippets.

@bkonyi
Created September 13, 2018 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkonyi/3dcbb962308582d6f7e8446c3f1c6994 to your computer and use it in GitHub Desktop.
Save bkonyi/3dcbb962308582d6f7e8446c3f1c6994 to your computer and use it in GitHub Desktop.
abstract class GeofencingPlugin {
static const MethodChannel _channel =
const MethodChannel('plugins.flutter.io/geofencing_plugin');
static Future<bool> initialize() async {
final callback = PluginUtilities.getCallbackHandle(callbackDispatcher);
await _channel.invokeMethod('GeofencingPlugin.initializeService',
<dynamic>[callback.toRawHandle()]);
}
static Future<bool> registerGeofence(
GeofenceRegion region,
void Function(List<String> id, Location location, GeofenceEvent event)
callback) {
if (Platform.isIOS &&
region.triggers.contains(GeofenceEvent.dwell) &&
(region.triggers.length == 1)) {
throw UnsupportedError("iOS does not support 'GeofenceEvent.dwell'");
}
final args = <dynamic>[
PluginUtilities.getCallbackHandle(callback).toRawHandle()
];
args.addAll(region._toArgs());
_channel.invokeMethod('GeofencingPlugin.registerGeofence', args);
}
/*
* … `removeGeofence` methods here …
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment