Closed achrafroui closed 6 months ago
the addGeofence function only accepts double greater or equal to 150m
That’s correct. The minimum radius the native geofencing apis respond to is 150 meters.
it doesn’t matter if you were to set it to zero — the native api will operate as if it were 150.
Your Environment
flutter doctor
):• No issues found!
{ Future.forEach( listOfZones, (ZoneModel zone) async => { if (List.of(await bg.BackgroundGeolocation.geofences)
.map((e) => e.identifier)
.toList()
.contains(zone.uid) ==
false)
{
if (zone.uid != null)
{
await addGeofence(zone),
}
}
});
}
Future addGeofence(ZoneModel zone) async {
log('fromAddGeofence: ${zone.geoRad!}');
// zone.geoRad! is between 40.0 and 176.0 => only 176.0 is added correctly and all the others are added 150.0m
await bg.BackgroundGeolocation.addGeofence(bg.Geofence(
identifier: zone.uid!,
radius: zone.geoRad!,
latitude: zone.geoLat!,
longitude: zone.geoLong!,
notifyOnEntry: false, // only notify on entry
notifyOnExit: true,
notifyOnDwell: true,
loiteringDelay: 5000, // 5 seconds
extras: {'name': zone.geoName})).then((bool success) {
log('[addGeofence] ${zone.geoName} success');
}).catchError((error) {
log('[addGeofence] FAILURE: $error');
});
}