secondsToTimeLeft method

String secondsToTimeLeft()

Seconds → countdown text. 75 → "01:15", 3725 → "01:02:05", 9 → "09"

Implementation

String secondsToTimeLeft() {
  final int h = this ~/ 3600;
  final int m = (this % 3600) ~/ 60;
  final int s = this % 60;
  if (h > 0) return "${h.twoDigits}:${m.twoDigits}:${s.twoDigits}";
  if (m > 0) return "${m.twoDigits}:${s.twoDigits}";
  return s.twoDigits;
}