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 = [];
  int round = 0;
  DateTime current = startDate;

  while (
      current.isBeforeOrSameAs(targetEndDate) && !_isAfterEndDate(current)) {
    if (!_isSkipDate(current)) {
      dates.add(current);
    }

    if (interval == Intervals.once) {
      break;
    } else if (interval == Intervals.monthly) {
      current = _getNextDate(startDate, offset: period * round)!;
    } else {
      current = _getNextDate(current)!;
    }

    round++;
  }

  return dates;
}