有没有办法在飞镖中将米转换为公里?

Is there a way to convert meters to kilometers in dart?

我正在使用geolocator: ^7.3.1 package 他们提到了一个计算两个地理点之间距离的函数,但是结果默认以米为单位

这怎么可能在 Km

    getDistance(){
    double distanceInMeters = Geolocator.distanceBetween(52.2165157, 6.9437819, 52.3546274, 4.8285838);
    print(distanceInMeters); // result comes in meters by default which is 144851.67191816124 meters
  }

我怎样才能得到以公里为单位的结果,并且短数字不像他们示例中的长数字?

转化

  double distanceInMeters = 144851.67191816124;
  double distanceInKiloMeters = distanceInMeters / 1000;
  double roundDistanceInKM =
      double.parse((distanceInKiloMeters).toStringAsFixed(2));

  print(distanceInMeters);
  print(distanceInKiloMeters);
  print(roundDistanceInKM);

输出

144851.67191816124
144.85167191816123
144.85

这有帮助吗?