更新2019/10/25
位置包现在具有一个函数(
serviceEnabled()),用于检测位置服务是否已启用,并按照文档中的说明和示例所示返回布尔值:
bool serviceStatus = await _locationService.serviceEnabled();if (service) { // service enabled} else { // service not enabled, restricted or permission denied}旧答案(包已过时)
使用地理位置,您可以检查位置服务是否正常运行。它通常比位置包包含更多的可定制性。
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 }


