rulerLabel function

String rulerLabel(
  1. double seconds
)

Formats a ruler label: 00:05, or 1:02:05 past an hour.

Implementation

String rulerLabel(double seconds) {
  final total = seconds.round();
  final h = total ~/ 3600;
  final m = (total ~/ 60) % 60;
  final s = total % 60;
  String two(int v) => v.toString().padLeft(2, '0');
  return h > 0 ? '$h:${two(m)}:${two(s)}' : '${two(m)}:${two(s)}';
}