Baseflow / Baseflow/flutter-geolocator
PositionStream does not work properly if location service is initially disabled then enabled
- Dominant language
- Dart
- Stars
- 1.3k
- Forks
- 803
- Avg merge
- 8h 16m
- Merged PRs (30d)
- 1
Description
## 🐛 Bug Report
I actually have two bugs that are somewhat similar. So instead of creating to reports I have them listed as 1) & 2).
1) Location stream throw a `LocationServicesDisabledException` when app is launched with location service disabled, but does not continue the steam when location service is then enabled by user using the notification drawer.
2) On new app install, after location permission is granted, I get an unhandled exception: `[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: The location service on the device is disabled.` if location service is initially disabled. Stream does not continue if location the then enabled.
I get the expected behavior when location service is initially enabled then disabled and the re-enabled after the #548 fix.
### Expected behavior
1) Location stream should continue after exception is thrown and location service is enabled.
2) **a)** Exception should be caught/handled by `Geolocator.getPositionStream(
desiredAccuracy: LocationAccuracy.medium, distanceFilter: 0)
.handleError((onError) {
log.e('handled position error: $onError');
}).listen((Position position) { log.d('$position');});`
**b)** location stream should continue after location service is enabled.
### Reproduction steps
1) **a)** Build basic app containing a PositionStream using a StreamSubscription or StreamProvider or a Streambuilder.
**b)** run the app while Location services are off and permission granted.
**c)** Turn on Location via Android Notification Drawer after exception is thrown.
2) **a)** Build basic app containing a PositionStream using a StreamSubscription or StreamProvider or a Streambuilder.
**b)** Install & run the app while Location services are off and grant permissions when prompted.
**c)** Turn on Location via Android Notification Drawer after exception is thrown.
### Configuration
**Version:** 6.1.2
**Platform:**
- [ ] :iphone: iOS
- [x] :robot: Android
Contributor guide
Research direction
Start with Geolocator.getPositionStream and reproduce both Android cases with location services disabled before permission or startup. Trace how LocationServicesDisabledException is emitted and whether the stream can resume after the notification-drawer toggle; done means the error is handled and the position stream continues in both reported scenarios.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, dart, flutter
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100