addGeofences static method
Adds a list of Geofence to be monitored by the native Geofencing API.
If a geofence(s) already exists with the configured Geofence.identifier, the previous one(s) will be deleted before the new one is inserted.
Example
List<Geofence> geofences = [
Geofence(
identifier: 'foo',
radius: 200,
latitude: 45.51921926,
longitude: -73.61678581,
notifyOnEntry: true,
),
Geofence(
identifier: 'bar',
radius: 200,
latitude: 45.51921926,
longitude: -73.61678581,
notifyOnEntry: true,
)
];
BackgroundGeolocation.addGeofences(geofences);
Implementation
static Future<bool> addGeofences(List<Geofence> geofences) async {
List<Map<String, dynamic>> rs =
geofences.map((Geofence geofence) => geofence.toMap()).toList();
return (await _methodChannel.invokeMethod<bool>('addGeofences', rs))
as FutureOr<bool>;
}