pace property Null safety

String pace

Get the time taken for the user to run a single reference distance unit.

The time to run 1 km or mile

Implementation

String get pace {
  if (speedMPS > 0) {
    final referenceDistance = isMetric ? Convert.kmToM : Convert.milesToM;
    final paceDuration = (referenceDistance.floor() / speedMPS).seconds;
    return '${paceDuration.inMinutes.withLeadingZero}:'
        '${paceDuration.secondsOnly.withLeadingZero}';
  }
  return '--:--';
}