I have a provider which is watching the position changes:
@riverpod
Stream<Position> positionStream(
PositionStreamRef ref,
) async* {
final locationService = ref.watch(locationServiceProvider);
yield* locationService.geolocator.getPositionStream(
locationSettings: locationService.getLocationSettings(),
);
}
I then watch the positionStreamProvider
provider in another provider.
@riverpod
Stream<List<MyObject>> myObjectsWithinRadius(MyObjectsWithinRadiusRef ref) {
final myLocation =
ref.watch(positionStreamProvider.select((value) => value.valueOrNull));
return ref
.watch(myObjectsWithinRadiusRepoProvider(
myLocation!.latitude, myLocation.longitude))
.getObjects();
}
A key feature of the app is to work in background as well as in foreground, and send notification as soon as an object is found within a certain radius. I have read about isolate but that seems kind of over complicated. I have also look at the flutter_background_geolocation package, but it costs more than 300 bucks for the single app license. Is there a simpler, latest way to get the providers run in the background?