Search
 
SCRIPT & CODE EXAMPLE
 

DART

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)}");
Comment

PREVIOUS NEXT
Code Example
Dart :: How to make checkbox shape to circular using flutter 
Dart :: convert long to date android 
Dart :: inkwell in image flutter not working 
Dart :: dart list remove range 
Dart :: flutter listview builder space between items 
Dart :: flutter button with icon and text 
Dart :: flutter gesturedetector 
Dart :: dart compare two lists 
Dart :: dart init Map 
Dart :: flutter alertdialog actionsoverflowdirecation 
Dart :: convert future<list list in flutter 
Dart :: check if string contain number dart flutter 
Dart :: flutter get operating system 
Dart :: flutter ElevatedButton 
Dart :: dart setters 
Dart :: show date picker flutter 
Dart :: loop over list dart 
Dart :: Flutter get each letter from string 
Dart :: dart substring 
Dart :: flutter block rotation 
Dart :: dart list generate 
Dart :: keyboard height flutter 
Dart :: dart singleton 
Dart :: flutter datacolumn center text 
Dart :: flutter disable focusable 
Dart :: prevent media query from rebuilding flutter widget 
Dart :: FloatingActionButton rtl flutter 
Dart :: dart void 
Dart :: flutter build async 
Dart :: flutter getit short 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =