我一直在尝试使用各种方法调用我的位置数据,包括IP位置API和Flutter插件,但是没有能够获得准确的位置数据。经过所有尝试后,我选择了Geolocator。但我一直遇到以下问题:
在我的初始化状态中调用它如下所示:
经过一些研究,我决定采用permission_handler来尝试检查权限。我声明了
我得到的是:
问题可能出在哪里?我已经尽力提及所有相关事项。任何见解都将非常有帮助。
I/flutter ( 5206): null
I/flutter ( 5206): GeolocationStatus.unknown
在我的初始化状态中调用它如下所示:
:
void initState() {
super.initState();
fetchData();
}
fetchData() async {
setState(() {
isLoading = true; //Data is loading
});
GeolocationStatus geolocationStatus =
await Geolocator().checkGeolocationPermissionStatus();
position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
if (position != null) {
lastPosition = await Geolocator()
.getLastKnownPosition(desiredAccuracy: LocationAccuracy.high);
}
...
if (position != null)
print(position);
else
print(lastPosition);
print(geolocationStatus);
setState(() {
isLoading = false; //Data has loaded
});
}
经过一些研究,我决定采用permission_handler来尝试检查权限。我声明了
PermissionStatus _status
并在我的fetchData()函数中添加了以下几行代码:PermissionHandler()
.checkPermissionStatus(PermissionGroup.location);
我得到的是:
No permissions found in manifest for: 3
,根据我的理解,我的清单文件已经包含了所需的权限。清单文件:https://gist.github.com/Purukitto/640d1637c05bdb1b69cc4309947c45d5
据我所知,将权限添加到清单中应该至少在应用程序中添加权限选项,但是构建并安装应用程序后,我的应用程序没有“权限”(附有截图)。问题可能出在哪里?我已经尽力提及所有相关事项。任何见解都将非常有帮助。