Flutter 如何在后台服务中获取纬度和经度?

Flutter 如何在后台服务中获取纬度和经度?,flutter,dart,Flutter,Dart,如问题所述。如何在Flatter中跟踪后台服务中的位置?只需使用该插件,您只需要一行代码 只需使用插件,您只需要一行代码 是带有插件和完整代码的官方链接。是带有插件和完整代码的官方链接 添加地理定位器:^4.0.3 导入“包:地理定位器/地理定位器.dart” 添加android和ios的权限 使用下面的代码 void getLocation() async { Position position = await Geolocator() .getCurrentPosition(desi

如问题所述。如何在Flatter中跟踪后台服务中的位置?

只需使用该插件,您只需要一行代码

只需使用插件,您只需要一行代码

是带有插件和完整代码的官方链接。

是带有插件和完整代码的官方链接

  • 添加
    地理定位器:^4.0.3
  • 导入
    “包:地理定位器/地理定位器.dart”
  • 添加android和ios的权限
  • 使用下面的代码

    void getLocation() async {
    Position position = await Geolocator()
        .getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
    print(position);
    }
    
  • 添加
    地理定位器:^4.0.3
  • 导入
    “包:地理定位器/地理定位器.dart”
  • 添加android和ios的权限
  • 使用下面的代码

    void getLocation() async {
    Position position = await Geolocator()
        .getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
    print(position);
    }