checkIfWithinRange method
Check if time is within range.
Used to disable AM/PM
.
Example: if user provided minHour
as 9
and maxHour
as 21
,
then the user should only be able to toggle AM/PM
for 9am
and 9pm
Implementation
bool checkIfWithinRange(DayPeriod other) {
final tempTime = Time(
hour: time.hour,
minute: time.minute,
second: time.second,
).setPeriod(other);
final expectedHour = tempTime.hour;
return widget.minHour! <= expectedHour && expectedHour <= widget.maxHour!;
}