toClockString method

String toClockString()

Returns a stopwatch-style string.

Implementation

String toClockString() {
  final d = _abs;
  final h = d.inHours;
  final m = d.inMinutes % 60;
  final s = d.inSeconds % 60;

  final mm = '$m'.padLeft(2, '0');
  final ss = '$s'.padLeft(2, '0');
  final body = h > 0 ? '$h:$mm:$ss' : '$m:$ss';

  return isNegative ? '-$body' : body;
}