Baseflow / flutter-geolocator

Android and iOS Geolocation plugin for Flutter
https://baseflow.com/
MIT License
1.24k stars 656 forks source link

[Bug]: Geolocator.getCurrentPosition() is not stable #1563

Open burekas7 opened 2 months ago

burekas7 commented 2 months ago

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 ```dart Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high); ```

Screenshots or video

Screenshots or video demonstration [Upload media here]

Version

12.0.0

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.19.5, on macOS 14.6.1 23G93 darwin-arm64, locale en-IL) • Flutter version 3.19.5 on channel stable at /Users/adi/Downloads/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 300451adae (5 months ago), 2024-03-27 21:54:07 -0500 • Engine revision e76c956498 • Dart version 3.3.3 • DevTools version 2.31.1 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/adi/Library/Android/sdk • Platform android-34-ext8, build-tools 34.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A507 • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2023.2) • Android Studio at /Applications/Android Studio.app/Contents • 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-17.0.9b1087.7-11185874) [✓] VS Code (version 1.92.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.94.0 [✓] Connected device (3 available) • Adi’s iPhone (mobile) • 00008020-001059A91EE9002E • ios • iOS 17.5.1 21F90 • macOS (desktop) • macos • darwin-arm64 • macOS 14.6.1 23G93 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.122 [✓] Network resources • All expected network resources are available. • No issues found! ```
ItayBarFaye commented 2 months ago

+1

ItayBarFaye commented 2 months ago

@burekas7, I think I found something to make it works. Try this - unawaited(Geolocator.getCurrentPosition()); await Geolocator.getPositionStream().first;

parasdaryanani commented 2 months ago

@ItayBarFaye thank you!