isTimeWithinRange method
Checks if the current time is within a time range (ignores date)
Implementation
bool isTimeWithinRange(TimeOfDay start, TimeOfDay end) {
final now = DateTime.now();
final currentMinutes = now.hour * 60 + now.minute;
final startMinutes = start.hour * 60 + start.minute;
final endMinutes = end.hour * 60 + end.minute;
if (startMinutes <= endMinutes) {
return currentMinutes >= startMinutes && currentMinutes <= endMinutes;
} else {
// Handles ranges that span midnight (e.g., 10:00 PM to 2:00 AM)
return currentMinutes >= startMinutes || currentMinutes <= endMinutes;
}
}