calculateMonthRange static method

List<int> calculateMonthRange(
  1. DateTime minDateTime,
  2. DateTime maxDateTime,
  3. int? currentYear
)

Implementation

static List<int> calculateMonthRange(
  DateTime minDateTime,
  DateTime maxDateTime,
  int? currentYear
) {
  int minMonth = 1, maxMonth = 12;
  int minYear = minDateTime.year;
  int maxYear = maxDateTime.year;

  if (minYear == currentYear) {
    minMonth = minDateTime.month;
  }
  if (maxYear == currentYear) {
    maxMonth = maxDateTime.month;
  }
  return [minMonth, maxMonth];
}