humanReadable property

String get humanReadable

Returns a human-readable string representation.

Example:

Duration(days: 2, hours: 3).humanReadable;
// '2 days'

Implementation

String get humanReadable {
  if (inDays > 0) {
    return '$inDays ${inDays == 1 ? 'day' : 'days'}';
  } else if (inHours > 0) {
    return '$inHours ${inHours == 1 ? 'hour' : 'hours'}';
  } else if (inMinutes > 0) {
    return '$inMinutes ${inMinutes == 1 ? 'minute' : 'minutes'}';
  } else if (inSeconds > 0) {
    return '$inSeconds ${inSeconds == 1 ? 'second' : 'seconds'}';
  } else {
    return '0 seconds';
  }
}