Is there a way to find out in Flutter if the GPS is activated or deactivated? I use the plugin location however there I get only the location and not the state of the GPS.>
Update 2019/10/25
The location package now has a function (serviceEnabled()
) to detect whether the location service is enabled and returns a bool as described in its docs and shown in the example:
bool serviceStatus = await _locationService.serviceEnabled();
if (service) {
// service enabled
} else {
// service not enabled, restricted or permission denied
}
Old answer (package outdated)
With geolocations you can check wether the location service is operational. It generally includes more customizability then the location package.
final GeolocationResult result = await Geolocation.isLocationOperational();
if(result.isSuccessful) {
// location service is enabled, and location permission is granted
} else {
// location service is not enabled, restricted, or location permission is denied
}