daysInMonth property

List<DateTime> daysInMonth

Returns a list of DateTimes representing the days in the same month as this DateTime.

Implementation

List<DateTime> get daysInMonth {
  final first = firstDayOfMonth;
  final daysBefore = first.weekday;
  final firstToDisplay = first.subtract(Duration(days: daysBefore));
  final last = lastDayOfMonth;
  var daysAfter = 7 - last.weekday;
  if (daysAfter == 0) {
    daysAfter = 7;
  }
  final lastToDisplay = last.add(Duration(days: daysAfter));
  return firstToDisplay.daysUpTo(lastToDisplay).toList();
}