stopwatchToSeconds method
Stop stopwatch and conditionally format elapsed time as seconds or ms
Implementation
String stopwatchToSeconds(Stopwatch stopwatch) {
stopwatch.stop();
final milliseconds = stopwatch.elapsedMilliseconds;
if (milliseconds > 1000) {
final roundedMilliseconds = (milliseconds / 1000).toStringAsFixed(2);
return '${roundedMilliseconds}s';
} else {
return '${milliseconds}ms';
}
}