retrieveDatesForMonth method

List<DayModel> retrieveDatesForMonth(
  1. DateTime month
)

Implementation

List<DayModel> retrieveDatesForMonth(final DateTime month) {
  // Little hack to get the number of days in the month.
  int daysInMonth = DateTime(
    month.year,
    month.month + 1,
    0,
  ).day;

  final List<DayModel> dayModels = [];

  for (int i = 1; i <= daysInMonth; i++) {
    var date = DateTime(month.year, month.month, i);

    dayModels.add(DayModel(
      date: date,
      isSelected: dateIsStartOrEnd(date),
      isStart: dateIsStart(date),
      isEnd: dateIsEnd(date),
      isSelectable: dateIsSelectable(date),
      isToday: areSameDay(date, DateTime.now()),
      isInRange: dateInSelectedRange(date),
    ));
  }

  return dayModels;
}