weeksInMonth property

int get weeksInMonth

Returns the number of unique weeks in the month, not just a division by 7.

Implementation

int get weeksInMonth {
  final firstWeekDays = 7 - startOfMonth.weekday - 1;
  final lastWeekDays = endOfMonth.weekday;
  final wholeWeeks = (daysInMonth - firstWeekDays - lastWeekDays) ~/ 7;
  return wholeWeeks + 2;
}