toVerboseString method
Formats this duration as compact parts such as 1h 2m 34s.
Implementation
String toVerboseString({bool includeSeconds = true}) {
final absolute = Duration(microseconds: inMicroseconds.abs());
final h = absolute.inHours;
final m = absolute.inMinutes % 60;
final s = absolute.inSeconds % 60;
final parts = <String>[
if (h > 0) '${h}h',
if (m > 0) '${m}m',
if (s > 0 && includeSeconds) '${s}s',
];
if (parts.isEmpty) return includeSeconds ? '0s' : '0m';
final body = parts.join(' ');
return isNegative ? '-$body' : body;
}