isBusinessHours method

bool isBusinessHours({
  1. int startHour = 9,
  2. int endHour = 17,
})

Returns true if the current time falls within business hours.

DateTime.now().isBusinessHours() // true (if between 09:00–17:00 on weekday)

Implementation

bool isBusinessHours({int startHour = 9, int endHour = 17}) =>
    isWeekday && hour >= startHour && hour < endHour;