Baseflow / Baseflow/flutter-geolocator
getCurrentPosition on Android12 and some Huawei models report an error TimeoutException
- Dominant language
- Dart
- Stars
- 1.3k
- Forks
- 803
- Avg merge
- 8h 16m
- Merged PRs (30d)
- 1
Description
## 🐛 Bug Report
The "getCurrentPosition" method is normal for models below Android 12. Android 12 and some Huawei models report an error "TimeoutException after 0:00:03.000000: Future not completed", but the "getLastKnownPosition" method is normal.
### Expected behavior
I/flutter (15995): 获取当前位置出错===TimeoutException after 0:00:03.000000: Future not completed
### Reproduction steps
```dart
try {
....
LocationPermission permission = await Geolocator.checkPermission();
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied ||
permission == LocationPermission.deniedForever) {
EasyLoading.showToast('定位失败!请确认授权或开启手机定位');
throw null;
}
Position _currentPosition;
_currentPosition = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.medium,
timeLimit: Duration(seconds: Platform.isIOS ? 5 : 3),
forceAndroidLocationManager: true);
....
} catch (e) {
print('获取当前位置出错===$e');
return catchErr();
}
```
### Configuration
**Version:** 8.2.0
**Platform:**
- [ ] :iphone: iOS
- [x] :robot: Android12
Contributor guide
Research direction
Start by reproducing the reported getCurrentPosition timeout on Android 12 and the affected Huawei models using the provided call, with forceAndroidLocationManager enabled and a three-second time limit. Compare it with getLastKnownPosition and behavior on older Android versions; done means identifying and fixing the Android-specific failure without regressing those cases.
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
- 35/100