getDates method

List<DateTime> getDates(
  1. DateTime start,
  2. DateTime end
)

Returns the dates of this weekday between start and end.

Implementation

List<DateTime> getDates(DateTime start, DateTime end) {
  final dates = <DateTime>[];
  for (var date = start; date.isBefore(end); date = date.add(const Duration(days: 1))) {
    if (date.weekday == index + 1) {
      dates.add(date);
    }
  }
  return dates;
}