getValidDays method
Get valid days based on the passed month.
If year or month is greater than current year or month or allowPastDates is true, it passes the whole list of possible days. If not, it returns a sublist of only current and future days. Else, it returns an empty list.
Implementation
List<int> getValidDays(int year, int month) {
final int maxDays = DaysInMonth.daysCountFromNumber(month, year: year);
if (year > _now.year || month > _now.month || allowPastDates) {
return _days.where((int day) => day <= maxDays).toList();
} else if (month == _now.month && year == _now.year) {
return _days
.where((int day) => day > _now.day && day <= maxDays)
.toList();
} else {
return <int>[];
}
}