How to check Location Service Status?
hasPermission only checking if permission is guaranteed. Is there any way to check location service / GPS status if it activated/disabled?
I would like to know as well, this is not stable my app don't know what to do and just keeps waiting for a location
Got a work around, not sure if it the best way because I'm very new to flutter but not new to programming. I changed the getLocation to this
Future<LocationData> getLocation() => _channel
.invokeMethod('getLocation')
.then((result) => LocationData.fromMap(result.cast<String, double>()))
.timeout(Duration(seconds: 1));
now I can Catch a timeout error like this
try {
currentLocation = await location.getLocation();
} on PlatformException {
currentLocation = null;
} catch (e) {
// can't get location, could be disabled!!!!
currentLocation = null;
print(e);
}
I'll look into adding this feature :)
Hey ! In 2.2 I've added serviceEnabled() and requestService() in order to check and request Location Service status. Let me know if it correspond to what you need :)
@Lyokone the method serviceEnabled() is not working on Android Pie. Do you know why?
Hey ! It seems to be working fine on my end ( I'm using a Pie device to test the example app). Let me check again today.
How to subscribe to serviceEnabled state changing?