prettyTime function

String prettyTime({
  1. int seconds = 0,
  2. int total = 0,
})

Time Display

Implementation

String prettyTime({
  int seconds = 0,
  int total = 0,
}) {
  int h = seconds~/3600;
  int m = seconds~/60;
  int s = seconds%60;
  String hs = 3600 > total ? '':'${h < 10 ? '0$h' : '$h'}:';
  String ms = 60 > total ? '':'${m < 10 ? '0$m' : '$m'}:';
  String ss = s < 10 ? '0$s' : '$s';
  return '$hs$ms$ss';
}