pretty_duration library

A utility to format Duration into a human-readable string.

Example:

final d = Duration(hours: 1, minutes: 42, seconds: 10);
print(prettyDuration(d)); // "1h 42m 10s"
print(prettyDuration(d, verbose: true)); // "1 hour 42 minutes 10 seconds"
print(prettyDuration(d, skipEmpty: true)); // "1h 42m"

Enums

DurationUnit
Enum representing units of time for prettyDuration. Each unit has a short, long, and plural representation.

Functions

prettyDuration(Duration duration, {bool verbose = false, bool skipEmpty = true, List<DurationUnit>? units, String? emptyText, bool cascade = false}) String
Formats a Duration into a readable string.