formatTook function
time as the time something took, as a ProgressList, a TaskList
and ProgressTask.summary write it: to the tenth of a second, cut
rather than rounded, under a minute (3.1 s), else as a clock in whole
seconds (01:05, then with the hours, 1:02:03).
The line an operation of an app's own ends with:
final clock = Stopwatch()..start();
// ...
final line = '✓ Built in ${formatTook(clock.elapsed)}';
// line: ✓ Built in 3.1 s
The point of 3.1 s is decimalSeparator, TwkStrings.decimalSeparator
for the widgets: 3,1 s.
Implementation
String formatTook(Duration time, {String decimalSeparator = '.'}) {
if (time.inSeconds < 60) {
final tenths = time.inMilliseconds ~/ 100;
return '${tenths ~/ 10}$decimalSeparator${tenths % 10} s';
}
return formatClock(time);
}