formatDistance static method

String formatDistance(
  1. double distance
)

Implementation

static String formatDistance(double distance) {
  if (distance > 1000) {
    distance = distance / 1000;
    return (distance).toStringAsFixed(
            distance.truncateToDouble() == distance ? 0 : 2) +
        " KM";
  } else {
    return distance.floor().toString() + " Meter";
  }
}