DateInterval constructor

DateInterval({
  1. DateTime? startDate,
  2. DateTime? endDate,
  3. int period = 1,
  4. Intervals interval = Intervals.once,
  5. Iterable<DateTime>? skipDates,
})

Creates an instance of the DateInterval class. period must be greater than 0 or it will throw an ArgumentError.

Implementation

DateInterval({
  DateTime? startDate,
  DateTime? endDate,
  this.period = 1,
  this.interval = Intervals.once,
  Iterable<DateTime>? skipDates,
}) {
  if (period < 1) {
    throw ArgumentError.value(
        period, 'period', 'Period must be 1 or greater.');
  }

  if (skipDates != null) {
    this.skipDates.addAll(skipDates);
  }

  this.startDate = startDate == null
      ? DateTime.now().withZeroTime()
      : startDate.withZeroTime();
  this.endDate = endDate?.withZeroTime();
}