formatHour static method

String formatHour(
  1. int hour,
  2. bool isAmPm
)

Implementation

static String formatHour(int hour, bool isAmPm) {
  if (!isAmPm) return hour.toString().padLeft(2, '0');

  if (hour == 0) return '12';
  if (hour > 12) return (hour - 12).toString();
  return hour.toString();
}