format method

String format({
  1. Map<TimeSpanUnit, String?>? labels,
  2. String separator = " ",
  3. bool pluralize = true,
  4. bool separateLabel = true,
})

Implementation

String format({
  Map<TimeSpanUnit, String?>? labels,
  String separator = " ",
  bool pluralize = true,
  bool separateLabel = true,
}) {
  labels ??= defaultLabels;
  return TimeSpanUnit.values.where((u) => u.get(this).isNotZero).map((unit) {
    final value = unit.get(this);
    return "$value${separateLabel ? " " : ""}${labels![unit]!.toString().pluralizeIf(value != 1 && pluralize)}";
  }).join(" ");
}