小编Urm*_*off的帖子

如何在获取 Flutter 中的当前位置时显示加载微调器?

我正在开发一个 Flutter 应用程序,它获取用户的当前位置,但是在获取位置时,它显示了这个丑陋的红色错误屏幕(一旦获取位置,它就会消失)。

而不是这个,我想显示一个加载微调器或启动画面。我已将问题缩小到此期间调用的方法initState()

void _setCurrentLocation() {
  Geolocator().getCurrentPosition().then((currLoc) {
    setState(() {
      currentLocation = currLoc;
    });
  });
}
Run Code Online (Sandbox Code Playgroud)

整个源文件也可以在 GitHub 上找到

提前致谢!

asynchronous future geolocation dart flutter

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

asynchronous ×1

dart ×1

flutter ×1

future ×1

geolocation ×1