clock property

String get clock

The time as a 12-hour clock string with AM/PM: "2:05:09 PM".

Implementation

String get clock {
  int h = hour ?? 0;
  int hour12 = h > 12 ? h - 12 : (h == 0 ? 12 : h);
  String m = (minute ?? 0).toString().padLeft(2, '0');
  String s = (second ?? 0).toString().padLeft(2, '0');
  return '$hour12:$m:$s $clockPhase';
}