Search code examples
flutterlocationfuture

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

  • I managed to solve it, if it happens to you check to do not call .getLocation() while a onChangedPosition listener is active.