RecurrentScheduledTrigger constructor

RecurrentScheduledTrigger({
  1. required RecurrentType type,
  2. required TimeOfDay time,
  3. DateTime? end,
  4. int separationCount = 0,
  5. int? maxNumberOfSampling,
  6. int? dayOfWeek,
  7. int? weekOfMonth,
  8. int? dayOfMonth,
  9. Duration? duration,
})

Create a trigger that resume sampling based on a recurrent scheduled date and time.

Implementation

RecurrentScheduledTrigger({
  required this.type,
  required this.time,
  this.end,
  this.separationCount = 0,
  this.maxNumberOfSampling,
  this.dayOfWeek,
  this.weekOfMonth,
  this.dayOfMonth,
  Duration? duration,
}) : super(
        period: const Duration(seconds: 1),
        duration: duration ?? const Duration(seconds: 2),
      ) {
  assert(separationCount >= 0, 'Separation count must be zero or positive.');
  if (type == RecurrentType.weekly) {
    assert(dayOfWeek != null,
        'dayOfWeek must be specified in a weekly recurrence.');
  } else if (type == RecurrentType.monthly) {
    assert(weekOfMonth != null || dayOfMonth != null,
        'Specify monthly recurrence using either dayOfMonth or weekOfMonth');
    assert(dayOfMonth == null || (dayOfMonth! >= 1 && dayOfMonth! <= 31),
        'dayOfMonth must be in the range [1-31]');
    assert(weekOfMonth == null || (weekOfMonth! >= 1 && weekOfMonth! <= 4),
        'weekOfMonth must be in the range [1-4]');
  }
}