onGeofence static method

StreamSubscription<GeofenceEvent> onGeofence(
  1. void callback(
    1. GeofenceEvent
    ), {
  2. Function? onError,
})

Subscribes to geofence events.

Implementation

static StreamSubscription<GeofenceEvent> onGeofence(
  void Function(GeofenceEvent) callback, {
  Function? onError,
}) {
  return events
      .where((event) => event.type == EventType.geofence)
      .map((event) => event.data)
      .where((data) => data is GeofenceEvent)
      .cast<GeofenceEvent>()
      .listen(callback, onError: onError);
}