formatSheenLength function Music

String formatSheenLength(
  1. Duration d,
  2. SheenMusicStrings s
)

A length as a listener says it: "30 min", "1 h 5 min" (never "0 min").

Implementation

String formatSheenLength(Duration d, SheenMusicStrings s) {
  final m = (d.inSeconds / 60).round().clamp(1, 1 << 30);
  return m < 60
      ? s.minutes.replaceAll('{m}', '$m')
      : s.hoursMinutes.replaceAll('{h}', '${m ~/ 60}').replaceAll('{m}', '${m % 60}');
}