Geolocator (13.0.2) is used to get location updates on iOS. Background mode is also used to get stream of coordinates even when app is in background. It is noticed that when app goes in background mode and come back again foreground mode, then even after cancelling position stream, app is still accessing the GPS. And this is confirmed by location icon shown in status bar of iPhone. However, app does not receive any location coordinates after cancelling the stream but that is draining the battery a lot.
StreamSubscription<dynamic>? _locationStream;
void startLocationStream() {
_locationStream = Geolocator.getPositionStream(
locationSettings: AppleSettings(
accuracy: LocationAccuracy.best,
allowBackgroundLocationUpdates: true,
),
).listen(coordinateLogic);
}
void stopLocationStream() {
_locationStream?.cancel().then((_) {
_locationStream = null;
});
}