onResume method

  1. @override
Future<bool> onResume()
override

Callback when this executor is resumed. Returns true if successfully resumed, false otherwise.

Implementation

@override
Future<bool> onResume() async {
  Geofence fence = Geofence.fromGeofenceSamplingConfiguration(
      samplingConfiguration as GeofenceSamplingConfiguration);

  // listen in on the location service
  deviceManager.manager.onLocationChanged
      .map((location) => GeoPosition.fromLocation(location))
      .listen((location) {
    // when a location event is fired, check if the new location creates a new [GeofenceDatum] event.
    // if so -- add it to the main stream.
    GeofenceDatum? datum = fence.moved(location);
    if (datum != null) geoFenceStreamController.add(datum);
  });

  return super.onResume();
}