Answers for "duration flutter from string"

1

flutter duration to string

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)}");
Posted by: Guest on September-23-2021

Code answers related to "duration flutter from string"

Browse Popular Code Answers by Language