formatDistance function Null safety

String formatDistance(
  1. double? meters
)

Convert the distance (as double) and return it as formatted string

Implementation

String formatDistance(double? meters) {
  if(meters==null) return "";
  var kms = meters/1000;
  if (kms<1) return [meters.toString(),tr("m")].join(" ");
  if (kms>=1) return [kms.toInt().toString(),tr("km")].join(" ");
  return meters.toString();
}