TimeWindow class
Time window constraint for when tasks can run.
Restrict task execution to specific hours of the day. Useful for syncing only during off-peak hours or specific business hours.
Example:
// Only sync between 2am-5am (off-peak)
final window = TimeWindow(
startHour: 2,
endHour: 5,
);
await TaskFlow.enqueue('sync', window: window);
Constructors
-
TimeWindow({required int startHour, required int endHour, List<
int> ? daysOfWeek})
Properties
-
daysOfWeek
→ List<
int> ? -
Days of week when window applies (0=Sun, 1=Mon, etc.)
null = all days
final
- endHour → int
-
End hour (0-23)
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- startHour → int
-
Start hour (0-23)
final
Methods
-
isNow(
) → bool - Check if current time is within window
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toMap(
) → Map< String, dynamic> - Convert to map
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- businessHours → TimeWindow
-
final
- nightOnly → TimeWindow
-
Common presets
final
- offPeak → TimeWindow
-
final
- weekdaysOffPeak → TimeWindow
-
final