toStringUnit method

String toStringUnit({
  1. bool days = true,
  2. bool hours = true,
  3. bool minutes = true,
  4. bool seconds = true,
  5. bool milliseconds = true,
  6. bool microseconds = true,
})

Implementation

String toStringUnit({
  bool days = true,
  bool hours = true,
  bool minutes = true,
  bool seconds = true,
  bool milliseconds = true,
  bool microseconds = true,
}) {
  if (days && inDays > 0) {
    return '$inDays d';
  } else if (hours && inHours > 0) {
    return '$inHours h';
  } else if (minutes && inMinutes > 0) {
    return '$inMinutes min';
  } else if (seconds && inSeconds > 0) {
    return '$inSeconds sec';
  } else if (milliseconds && inMilliseconds > 0) {
    return '$inMilliseconds ms';
  } else if (microseconds && inMicroseconds > 0) {
    return '$inMicroseconds μs';
  } else {
    return toString();
  }
}