📜  颤动到字符串的持续时间 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:47.596000             🧑  作者: Mango

代码示例1
You can use Duration and implement this method:

String _printDuration(Duration duration) {
  String twoDigits(int n) => n.toString().padLeft(2, "0");
  String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60));
  String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60));
  return "${twoDigits(duration.inHours)}:$twoDigitMinutes:$twoDigitSeconds";
}
Usage:

final now = Duration(seconds: 30);
print("${_printDuration(now)}");