formatDuration method

String formatDuration(
  1. int timeCount
)

Implementation

String formatDuration(int timeCount) {
  int hour = timeCount ~/ 3600;
  int minute = (timeCount % 3600) ~/ 60;
  String minuteShow = minute <= 9 ? "0$minute" : "$minute";
  int second = timeCount % 60;
  String secondShow = second <= 9 ? "0$second" : "$second";

  if (hour > 0) {
    String hourShow = hour <= 9 ? "0$hour" : "$hour";
    return '$hourShow:$minuteShow:$secondShow';
  } else {
    return '$minuteShow:$secondShow';
  }
}