toStringUnit method
String
toStringUnit(
{ - bool days = true,
- bool hours = true,
- bool minutes = true,
- bool seconds = true,
- bool milliseconds = true,
- bool microseconds = true,
})
Implementation
String toStringUnit({
bool days = true,
bool hours = true,
bool minutes = true,
bool seconds = true,
bool milliseconds = true,
bool microseconds = true,
}) {
if (days && inDays > 0) {
return '$inDays d';
} else if (hours && inHours > 0) {
return '$inHours h';
} else if (minutes && inMinutes > 0) {
return '$inMinutes min';
} else if (seconds && inSeconds > 0) {
return '$inSeconds sec';
} else if (milliseconds && inMilliseconds > 0) {
return '$inMilliseconds ms';
} else if (microseconds && inMicroseconds > 0) {
return '$inMicroseconds μs';
} else {
return toString();
}
}