有没有办法在 Flutter 中找出 GPS 是激活还是停用?
我使用插件location然而,我只得到位置,而不是 GPS 的状态。
更新:(地理定位器8.0.1)
bool isLocationEnabled = await Geolocator.isLocationServiceEnabled();
以前的解决方案:
接受的答案使用过时的插件,您可以使用地理定位器 plugin,
var geoLocator = Geolocator();
var status = await geoLocator.checkGeolocationPermissionStatus();
if (status == GeolocationStatus.denied)
// Take user to permission settings
else if (status == GeolocationStatus.disabled)
// Take user to location page
else if (status == GeolocationStatus.restricted)
// Restricted
else if (status == GeolocationStatus.unknown)
// Unknown
else if (status == GeolocationStatus.granted)
// Permission granted and location enabled
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)