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