我正在开发一个 Flutter 应用程序,它获取用户的当前位置,但是在获取位置时,它显示了这个丑陋的红色错误屏幕(一旦获取位置,它就会消失)。
而不是这个,我想显示一个加载微调器或启动画面。我已将问题缩小到此期间调用的方法initState():
void _setCurrentLocation() {
Geolocator().getCurrentPosition().then((currLoc) {
setState(() {
currentLocation = currLoc;
});
});
}
Run Code Online (Sandbox Code Playgroud)
整个源文件也可以在 GitHub 上找到。
提前致谢!