【问题标题】:PlatformException(ERROR, Failed to get location., null) in Flutter location: ^1.4.1Flutter 位置中的 PlatformException(错误,无法获取位置。,null):^1.4.1
【发布时间】:2020-03-26 21:39:48
【问题描述】:

我来了

PlatformException(错误,获取位置失败。,null)

使用颤振从设备获取位置时,位置:^1.4.1。有人可以帮忙吗?

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    _getLocation();
    return Container();
  }

  Future<Map<String, double>> _getLocation() async {
    var location = new Location();
    try {
      var _permission = await location.hasPermission();
      print(_permission);
      var currentlocation = await location.getLocation();
      print(currentlocation["latitude"]);
      return currentlocation;
    } on Exception catch (e) {
      print(e);
    }
  }
}

堆栈跟踪 -

I/flutter (28694): true
I/flutter (28694): PlatformException(ERROR, Failed to get location., null)

【问题讨论】:

  • 我有同样的问题,我有一个包含一组文档的集合,每个文档都有一个归档类型 Geopoint,我想翻译一些纬度,经度到地址,其中一些工作正常,但其他不起作用并给我这个异常 PlatformException(failed, Failed, null) ,我不知道为什么..你找到解决方案了吗

标签: android flutter geolocation flutter-dependencies


【解决方案1】:

所以你通过flutter pub get 拉了那个包... 您是否还重建了整个项目? 可能是因为它没有构建插件的原生端。

Stop and Re-Run 可能会有所帮助。

【讨论】:

    猜你喜欢
    • 2022-07-12
    • 1970-01-01
    • 1970-01-01
    • 2021-09-06
    • 1970-01-01
    • 1970-01-01
    • 2020-12-26
    • 2023-01-20
    • 1970-01-01
    相关资源
    最近更新 更多