formatSpeed static method

String formatSpeed(
  1. double speedKmh, {
  2. bool useImperialUnits = false,
})

//////////// //////////// Formats a speed value (in km/h) based on the desired unit system

Implementation

// II.B - Speed Formatting
///////////////
/// Formats a speed value (in km/h) based on the desired unit system
static String formatSpeed(double speedKmh, {bool useImperialUnits = false}) {
  if (useImperialUnits) {
    final speedMph = speedKmh * 0.621371;
    return '${speedMph.round()} mph';
  } else {
    return '${speedKmh.round()} km/h';
  }
}