toHhMmSs method

String toHhMmSs()

Returns a zero-padded HH:MM:SS string (e.g. "01:23:45").

Useful for video players and stopwatches.

Implementation

String toHhMmSs() {
  final abs = this.abs();
  final h = abs.inHours.toString().padLeft(2, '0');
  final m = abs.inMinutes.remainder(60).toString().padLeft(2, '0');
  final s = abs.inSeconds.remainder(60).toString().padLeft(2, '0');
  return '${isNegative ? '-' : ''}$h:$m:$s';
}