Flutterlocation: Stuck at await _locationService.getLocation(); When GPS is off

Created on 17 Nov 2019  路  4Comments  路  Source: Lyokone/flutterlocation

Describe the bug
I simplified code with this example
When GPS is off by default, await location.getLocation() stuck it never return
any next print statement never execute.
But When I enable GPS by default and launch application then it works

try{
      currentLocation = await location.getLocation();
      print("*******WORKING******");
 } on PlatformException catch (e) {
      print("*******PLATFORM EXCEPTION RETURNED******");
    }

Expected behavior
It should not be stuck under await, either it should throw an exception which I already handling

Tested on:

  • Android, API Level XX [e.g. 28], simulator or real device
  • Android, Emulator

Other plugins:

  • List of others Flutter plugins that could interfere
    http: ^0.12.0+2
    location: ^2.3.5
    google_maps_flutter: ^0.4.0
inactive

Most helpful comment

I got the same problem.

For now, I use this solution, This is a bad way but it works.

Screen Shot 2019-11-26 at 14 18 15

All 4 comments

Same is happening to me when I don't allow to share the location

I got the same problem.

For now, I use this solution, This is a bad way but it works.

Screen Shot 2019-11-26 at 14 18 15

It is happening to me only on Android even if GPS is on and location is shared.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings