【发布时间】: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