format property

String get format

Formats this duration using the most appropriate representation:

  • DD:HH:mm:ss if duration is at least 1 day
  • HH:mm:ss if duration is at least 1 hour
  • mm:ss otherwise

Example:

Duration(seconds: 45).format; // "00:45"

Implementation

String get format {
  if (inDays > 0) {
    return formatDDHHMMSS;
  } else if (inHours > 0) {
    return formatHHMMSS;
  } else {
    return formatMMSS;
  }
}