GeofenceService class abstract

Service interface for geofencing operations.

Example:

// Add a circular geofence
await Locus.geofencing.add(Geofence(
  identifier: 'office',
  latitude: 37.7749,
  longitude: -122.4194,
  radius: 100.0,
  notifyOnEntry: true,
  notifyOnExit: true,
));

// Add a polygon geofence
await Locus.geofencing.addPolygon(PolygonGeofence(
  identifier: 'campus',
  vertices: [
    GeoPoint(latitude: 37.42, longitude: -122.08),
    GeoPoint(latitude: 37.43, longitude: -122.08),
    GeoPoint(latitude: 37.43, longitude: -122.07),
    GeoPoint(latitude: 37.42, longitude: -122.07),
  ],
));

// Listen to geofence events
Locus.geofencing.events.listen((event) {
  print('Geofence ${event.identifier}: ${event.action}');
});
Implementers

Constructors

GeofenceService()

Properties

events Stream<GeofenceEvent>
Stream of geofence crossing events.
no setter
hashCode int
The hash code for this object.
no setterinherited
polygonEvents Stream<PolygonGeofenceEvent>
Stream of polygon geofence events.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
workflowEvents Stream<GeofenceWorkflowEvent>
Stream of geofence workflow events.
no setter

Methods

add(Geofence geofence) Future<bool>
Adds a single geofence.
addAll(List<Geofence> geofences) Future<bool>
Adds multiple geofences.
addPolygon(PolygonGeofence polygon) Future<bool>
Adds a polygon geofence.
addPolygons(List<PolygonGeofence> polygons) Future<int>
Adds multiple polygon geofences.
clearWorkflows() → void
Clears all registered workflows.
exists(String identifier) Future<bool>
Checks if a geofence exists.
get(String identifier) Future<Geofence?>
Gets a geofence by identifier.
getAll() Future<List<Geofence>>
Gets all registered geofences.
getAllPolygons() Future<List<PolygonGeofence>>
Gets all registered polygon geofences.
getPolygon(String identifier) Future<PolygonGeofence?>
Gets a polygon geofence by identifier.
getWorkflowState(String workflowId) GeofenceWorkflowState?
Gets the current state of a workflow.
isInActiveGeofence() Future<bool>
Checks if currently inside any active geofence.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onGeofence(void callback(GeofenceEvent), {Function? onError}) StreamSubscription<GeofenceEvent>
Subscribes to geofence events.
onGeofencesChange(void callback(dynamic), {Function? onError}) StreamSubscription
Subscribes to geofence list changes.
onWorkflowEvent(void callback(GeofenceWorkflowEvent), {Function? onError}) StreamSubscription<GeofenceWorkflowEvent>
Subscribes to workflow events.
polygonExists(String identifier) Future<bool>
Checks if a polygon geofence exists.
registerWorkflows(List<GeofenceWorkflow> workflows) → void
Registers geofence workflows.
remove(String identifier) Future<bool>
Removes a geofence by identifier.
removeAll() Future<bool>
Removes all geofences.
removeAllPolygons() Future<void>
Removes all polygon geofences.
removePolygon(String identifier) Future<bool>
Removes a polygon geofence by identifier.
startMonitoring() Future<bool>
Starts geofence-only monitoring mode.
stopWorkflows() → void
Stops all active workflows.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited