formatDistance static method

String formatDistance(
  1. LatLng a,
  2. LatLng b, {
  3. bool inKm = true,
})

Implementation

static String formatDistance(LatLng a, LatLng b, {bool inKm = true}) {
  final meters = calculateDistance(a, b);
  if (inKm) {
    return '${(meters / 1000).toStringAsFixed(2)} km';
  } else {
    return '${(meters * 0.000621371).toStringAsFixed(2)} miles';
  }
}