Reputation: 894
I have the following StreamSubscription that get's the user's location every 10 meters:
StreamSubscription < LocationResult > subscription = Geolocation.locationUpdates(
accuracy: LocationAccuracy.best,
displacementFilter: 10.0,
inBackground: true,
)
.listen((result) {
if (result.isSuccessful) {
saveResult(result);
} else {}
});
saveResult(result) is then called to save the result in firestore. Everything works as expected when the app is in the foreground, but when it goes to the background it will sometime keep saving the results for a few hundred meters, then stop saving. The results continue to being buffered though, for when the app comes back in focus, saveResult(result) is executed repeatedly and you can watch the results being added one after the other, rapidly, in firestore. Is there a way to have a more consistent way of updating the results with the app in the background?
Upvotes: 0
Views: 1724
Reputation: 5254
I was also facing this issue and I developed my own plugin for background location updates, here it is, flutter_background_location. Its ok with android but I am not sure about iOS as I don't own a mac.
Upvotes: 1