Skip to content

GeofencesChangeEvent

class GeofencesChangeEvent

Geofence monitoring change delivered to BackgroundGeolocation.onGeofencesChange.

The SDK can only monitor a finite number of geofences simultaneously. As the device moves, it activates the geofences closest to the current position and deactivates those that are too far away. This event fires whenever that set changes — reporting which geofences just became active (on) and which were just removed from active monitoring (off).

BackgroundGeolocation.onGeofencesChange((GeofencesChangeEvent event) {
  for (final geofence of event.on) {
    print('[onGeofencesChange] Activated: ${geofence.identifier}');
  }
  for (final identifier of event.off) {
    print('[onGeofencesChange] Deactivated: ${identifier}');
  }
});

Members

off

List<String> off

Identifiers of geofences that were just deactivated and are no longer being monitored.

on

List<Geofence> on

Geofences that just became active and are now being monitored.