getFormatter static method
Get the most appropriate format for a given duration
Implementation
static String Function(Duration) getFormatter({
bool showHours = true,
bool showMinutes = true,
bool showSeconds = true,
bool showMilliseconds = false,
String? customPattern,
}) {
if (customPattern != null) {
return (duration) => formatCustom(duration, customPattern);
}
if (showMilliseconds) {
return formatWithMilliseconds;
}
if (showHours && showMinutes && showSeconds) {
return formatHHMMSS;
} else if (showMinutes && showSeconds) {
return formatMMSS;
} else if (showSeconds) {
return formatSS;
} else {
return formatSmart;
}
}