首页 > 解决方案 > MissingPluginException(MissingPluginException(在通道 lyokone/location 上找不到方法 getLocation 的实现))

问题描述

我正在创建我的第一个颤振应用程序,所以希望我没有问任何愚蠢的问题。我正在使用颤振的位置插件,我不断收到以下错误:

MissingPluginException (MissingPluginException(No implementation found for method getLocation on channel lyokone/location))

这是我的代码:

void _trackLocation() async {
    int time = 0;
    Location location = new Location();
    LocationData start = await location.getLocation();
    double lat1 = start.latitude;
    double lon1 = start.longitude;
    await Future.delayed(Duration(seconds: 5));
    LocationData end = await location.getLocation();
    double lat2 = end.latitude;
    double lon2 = end.longitude;
    print(lat1);
    setState(() {
      //distance = _getDistance(lat1, lon1, lat2, lon2);
      distance += 1;
    });

我知道已经有人问过这个问题,但是没有一个解决方案对我有用。我已经尝试过清理并重建应用程序,但我一直收到同样的错误。我不知道该怎么做,所以任何事情都会不胜感激。谢谢!

标签: flutter

解决方案


推荐阅读