'Flutter Location packages does not return current location on iOS
I'm stuck with this problem, If I try to call:
Location location = Location();
LocationData data = await location.getLocation();
The future does never return anything, it just keeps going without returning values. This is kinda weird because in my application I also have google maps and they find without a problem my position, so it is not a GPS / Permission problem.
On Android this problem does not exist, just on iOS (Targetting iOS 10.0 at the moment).
Edit:
After more tests I concluded that it actually works, but just the first time the app is opened, every other request to that method does not respond.
Solution 1:[1]
I managed to solve it, if it happens to you check to do not call .getLocation() while a onChangedPosition listener is active.
Solution 2:[2]
To use it in iOS, you have to add this permission in Info.plist :
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
Solution 3:[3]
I was struggling with this for a while. Go to your simulator settings at the top bar, click the 'Features' ==> 'Location' pick from various locations to mock: [None, Custom Location, City Run, City Bicycle Ride, Freeway Drive, Apple].
Should work then provided Info.plist is properly set-up, and Android Manifest is correct.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Gabriel Costache |
Solution 2 | |
Solution 3 | FredTheMarvelous |