Flutter Location包在调用serviceEnabled()时生成平台异常



Flutter 2.0.6,定位包4.1.1。

这段代码。。。

try {
_serviceEnabled = await location.serviceEnabled();
} on PlatformException catch (err) {    
print ("Platform exception calling serviceEnabled(): $err");
_serviceEnabled = false; 
}

生成:调用serviceEnabled((的平台异常:PlatformException(SERVICE_STATUS_ERROR,无法确定定位服务状态,null,null(

但有趣的是:当我在三星Galaxy S8上运行发布版本时,只有才会出现这个错误。如果我在S8上运行调试构建,或者如果我在android模拟器上运行发布或调试构建,则不会引发错误。我已经尝试了几种不同的模拟器配置,特别是一种配置与S8-Android版本9(SDK 28(非常接近的模拟器,并且屏幕大小相同。

任何关于如何调查为什么会发生这种情况的建议都将不胜感激。

initLocation() async {
try {
_serviceEnabled = await location.serviceEnabled();
} on PlatformException catch (err) {
print("Platform exception calling serviceEnabled(): $err");
_serviceEnabled = false;
// location service is still not created
initLocation(); // re-invoke himself every time the error is catch, so until the location service setup is complete
}   }

从initState((调用initLocation((

@override void initState() {
super.initState();
initLocation(); } 

问题与一些Android超时进程有关,因此递归调用

信用发行线程

最新更新