1

I'm trying to access a location in Flutter via the Geolocator package. This works well but the location permission check has some sort of bug.

I check if the location service is enabled. Once it's accessed i check the users permission and then return location. This works quite as intended, but there is a problem with the first step. I use

Geolocator.isLocationServiceEnabled()

to check if the location service is enabled. Unfortunately, this function just returns in some cases which leads to the whole function not returning, even though the location service is activated.

I already searched in different forums for answers and it seems to be a known problem although i didn't find a solution yet.

Attemps i tried to get access to GPS but failed:

  • turning GPS off and on again
  • closing and opening the app again
  • inserted
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

in AndroidManifest

  • hot restart in IDE

I could just access the location if i re-run debugging, but not each time...

Does anybody have a clue how to get this built-in function to work as intended?

Thanks in advance!

icecase
  • 23
  • 3

1 Answers1

0

I found a workaround. I used the permission_handler package and replaced

Geolocator.isLocationServiceEnabled()

with

final hasPermission = await Permission.locationWhenInUse.serviceStatus.isEnabled;
icecase
  • 23
  • 3