checkGeofenceStream method
Check the stream of geofence status updates
Implementation
void checkGeofenceStream(GeoFirePoint center, double radius) {
geofenceStatusStream = Stream.periodic(Duration(seconds: 5)).listen((
_,
) async {
if (position != null) {
double distanceInMeters = Geolocator.distanceBetween(
position!.latitude,
position!.longitude,
center.latitude,
center.longitude,
);
// Update geofence status based on distance
geofenceStatus = (distanceInMeters <= radius)
? "Inside Geofence"
: "Outside Geofence";
debugPrint("Geofence Status: $geofenceStatus");
}
});
}