datesOfMonths method

List<DateTime> datesOfMonths({
  1. WeekDays startDay = WeekDays.monday,
})

Returns list of all dates of month. All the dates are week based that means it will return array of size 42 which will contain 6 weeks that is the maximum number of weeks a month can have.

Implementation

List<DateTime> datesOfMonths({WeekDays startDay = WeekDays.monday}) {
  final monthDays = <DateTime>[];
  for (var i = 1, start = 1; i < 7; i++, start += 7) {
    monthDays
        .addAll(DateTime(year, month, start).datesOfWeek(start: startDay));
  }
  return monthDays;
}