SchedulerConfig constructor
SchedulerConfig({
- required String eventKey,
- required TriggerType triggerType,
- int? triggerCount,
- DateTime? triggerTime,
- Duration? recurrenceInterval,
- int? recurrenceCount,
- RecurrenceType recurrenceType = RecurrenceType.none,
- int? maxRecurrences,
- DateTime? endTime,
- required VoidCallback onEvent,
- VoidCallback? recurrenceOnEvent,
- dynamic onStateUpdate()?,
Creates a new scheduler configuration.
Throws assertions if required parameters are missing based on trigger type:
- For count triggers: triggerCount must be provided
- For time triggers: triggerTime must be provided
- For count recurrence: recurrenceCount must be provided
- For time recurrence: recurrenceInterval must be provided
Implementation
SchedulerConfig({
required this.eventKey,
required this.triggerType,
this.triggerCount,
this.triggerTime,
this.recurrenceInterval,
this.recurrenceCount,
this.recurrenceType = RecurrenceType.none,
this.maxRecurrences,
this.endTime,
required this.onEvent,
this.recurrenceOnEvent,
this.onStateUpdate,
}) {
assert(
triggerType == TriggerType.count
? triggerCount != null
: triggerTime != null,
'triggerCount must be provided when triggerType is count, triggerTime must be provided when triggerType is time',
);
assert(
recurrenceType == RecurrenceType.none ||
(recurrenceType == RecurrenceType.count && recurrenceCount != null) ||
(recurrenceType == RecurrenceType.time && recurrenceInterval != null),
'recurrenceCount must be provided when recurrenceType is count, recurrenceInterval must be provided when recurrenceType is time',
);
assert(
triggerType == TriggerType.time
? (recurrenceInterval != null)
: (triggerCount != null),
'Time trigger requires recurrenceInterval, count trigger requires triggerCount',
);
}