getDatesThrough method

Iterable<DateTime> getDatesThrough(
  1. DateTime targetEndDate
)

Returns an Iterable<DateTime> of all valid dates between the configured startDate and the earliest of the configured endDate (if present) or the supplied targetEndDate.

Implementation

Iterable<DateTime> getDatesThrough(DateTime targetEndDate) {
  final List<DateTime> dates = [];
  DateTime current = startDate;

  bool isValid(DateTime date) =>
      date.isBeforeOrSameAs(targetEndDate) && !_isAfterEndDate(date);

  while (isValid(current)) {
    if (!_isSkipDate(current) && !dates.contains(current)) {
      dates.add(current);
    }

    if (interval == Intervals.once) {
      break;
    }

    current = _getNextDate(current)!;
  }

  return dates;
}