cToDistance property

String get cToDistance

Converts a numeric value in meters to a human-readable distance representation with the appropriate unit (meters or kilometers).

Returns a formatted string representing the distance, e.g., "5.75 m" or "2.34 km".

Implementation

String get cToDistance {
  var distance = '';
  if (this >= 1000) {
    distance = '${(this / 1000).toStringAsFixed(2)} km';
  } else {
    distance = '${(this).toStringAsFixed(2)} m';
  }
  return distance.replaceAll('.00', '');
}