-
-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Geolocator.getCurrentPosition() is not stable #1563
Comments
+1 |
@burekas7, I think I found something to make it works. Try this - |
@ItayBarFaye thank you! |
Same the issue some on Android real devices =<< |
Version 13.0.2, Android There seems to be a much older version of this post from 2020: I'd like to add some data; this problem occurs for our project, and I've collected some data on how often it happens. I am using @ItayBarFaye's fix and the bug continues to appear. It seems to be intermittent, yet consistent. I am simply restarting my app with a 6 second timer. If the getPositionStream/getCurrentPosition succeeds by then, it logs a success. if it does not, it logs a failure. I can't seem to determine a cause; it's certainly not network connectivity. I've chosen to mitigate this by simply using the cached version and updating the position with an unawaited call to the getPositionStream: Future<LatLng?> tryGetLocation() async {
unawaited(Geolocator.getCurrentPosition());
position = await Geolocator.getLastKnownPosition();
if (position != null) {
Geolocator.getPositionStream().first.then((value) {
position = value;
});
return location;
}
else {
position = await Geolocator.getPositionStream().first;
}
return location;
} |
Please check the following before submitting a new issue.
Please select affected platform(s)
Steps to reproduce
Hi,
I'm running my appp on iOS 17.5.1 (real device)
(Precise Location in settings is ON, and all the relevant permissions in info.plist are there)
Using geolocator version 12.0.0
When try to get a location using "Geolocator.getCurrentPosition()"
(desiredAccuracy: LocationAccuracy.high but also with "best")
Somtimes it takes few seconds, sometimes few minutes, and sometimes it seems like it never ends.
What could be the reason and how can I solve this?
Is there any limitation in iOS or something?
(It was ok in the past)
(It happens also with "location' package, but there is it worst, it never completes)
Thanks
Expected results
A desired result that will end after a maximum of a few seconds.
Actual results
Get a resopnse agter few secongs maximum.
Code sample
Code sample
Screenshots or video
Screenshots or video demonstration
[Upload media here]
Version
12.0.0
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: