formatSeconds property

String get formatSeconds

将描述转为 HH:mm:ss

Implementation

String get formatSeconds {
  if (this == null) {
    return '';
  }
  final d = Duration(seconds: this!);
  final h = d.inHours;
  final m = (d.inMinutes % 60).toString().padLeft(2, '0');
  final s = (d.inSeconds % 60).toString().padLeft(2, '0');

  if (h == 0) {
    return '$m:$s';
  }
  return '${h.toString().padLeft(2, '0')}:$m:$s';
}