我得到
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);
}
}
}
Stacktrace-
I/flutter (28694): true
I/flutter (28694): PlatformException(ERROR, Failed to get location., null)
答案 0 :(得分:0)
因此,您通过flutter pub get
将该包拉入了...
您是否还重建了整个项目?
可能是因为它没有构建插件的本机部分。
Stop and Re-Run
可能会有帮助。