Baseflow / Baseflow/flutter-geolocator
[Bug]: Geolocator.getCurrentPosition hangs after app restart
- Dominant language
- Dart
- Stars
- 1.3k
- Forks
- 803
- Avg merge
- 8h 16m
- Merged PRs (30d)
- 1
Description
### Please check the following before submitting a new issue.
- [x] I have searched the [existing issues](https://github.com/baseflow/flutter-geolocator/issues).
- [x] I have carefully [read the documentation](https://github.com/Baseflow/flutter-geolocator/blob/main/geolocator/README.md) and verified I have added the required platform specific configuration.
### Please select affected platform(s)
- [x] Android
- [ ] iOS
- [ ] Linux
- [ ] macOS
- [ ] Web
- [ ] Windows
### Steps to reproduce
In an Android app, request GeoLocator.getCurrentPosition().
First time is fast. I use "medium".
Then, either kill the app and re-open, or, do a hot reload if debugging.
Second time, or perhaps one or two times after, the app will hang during getCurrentPosition.
### Expected results
It should again work fast after killing the app and restarting.
### Actual results
After opening the app, closing the app, then re-opening, (maybe cycle that 1-3 times), Geolocator will hang for 16-20 seconds before finally getting a position.
### Code sample
Code sample
```dart
Future getCurrentLocation() async {
const locationSettings = LocationSettings(
accuracy: LocationAccuracy.medium, // Medium accuracy (100-500m)
);
final position = await Geolocator.getCurrentPosition(
locationSettings: locationSettings,
);
return position;
}
```
### Screenshots or video
Screenshots or video demonstration
[Upload media here]
### Version
13.0.2
### Flutter Doctor output
Doctor output
```console
[√] Flutter (Channel beta, 3.32.0-0.1.pre, on Microsoft Windows [Version 10.0.22],
locale en-US) [778ms]
• Flutter version 3.32.0-0.1.pre on channel beta at C:\Flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision eeb81b9a8a (4 days ago), 2025-04-11 12:11:52 -0700
• Engine revision 72ee26e314
• Dart version 3.8.0 (build 3.8.0-278.1.beta)
• DevTools version 2.45.0
[√] Windows Version (11 Home 64-bit, 22H2, 2009) [4.9s]
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [2.6s]
• Platform android-35, build-tools 35.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
• All Android licenses accepted.
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.13.6) [403ms]
• Visual Studio Community 2022 version 17.13.35931.197
• Windows 10 SDK version 10.0.22000.0
[√] Android Studio (version 2023.2) [25ms]
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
[√] VS Code (version 1.99.2) [23ms]
• Flutter extension version 3.108.0
[√] Network resources [458ms]
• All expected network resources are available.
• No issues found!```
Contributor guide
Assessment
This issue has not been assessed yet.