📅  最后修改于: 2022-03-11 14:55:47.596000             🧑  作者: Mango
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)}");