geofences property
Retrieve all Geofence.
Fetch a list of all Geofence. If there are no geofences being monitored, you'll receive an empty List
.
Example
List<Geofence> geofences = await BackgroundGeolocation.geofences;
print('[getGeofences: ${geofences}');
Implementation
static Future<List<Geofence>> get geofences async {
List<dynamic> geofences =
(await _methodChannel.invokeListMethod('getGeofences')) ?? [];
List<Geofence> rs = [];
geofences.forEach((dynamic data) {
dynamic loiteringDelay = data['loiteringDelay'];
List<List<double>> vertices = [];
if (data['vertices'] != null) {
List<Object?> tmp = data['vertices'];
tmp.forEach((vertex) {
List<double> v = List.from(vertex as List);
vertices.add(v);
});
}
rs.add(Geofence(
identifier: data['identifier'],
radius: data['radius'],
latitude: data['latitude'],
longitude: data['longitude'],
notifyOnEntry: data['notifyOnEntry'],
notifyOnExit: data['notifyOnExit'],
notifyOnDwell: data['notifyOnDwell'],
loiteringDelay: (loiteringDelay.runtimeType == double)
? loiteringDelay.round()
: loiteringDelay,
vertices: vertices,
extras: (data['extras'] != null)
? data['extras'].cast<String, dynamic>()
: {}));
});
return rs;
}