isValidMonthYear static method

bool isValidMonthYear(
  1. String input
)

Implementation

static bool isValidMonthYear(String input) {
  try {
    final date = DateFormat('MM-yyyy').parseStrict(input);
    // Check if the month is between 1 and 12
    return date.month >= 1 && date.month <= 12;
  } catch (_) {
    return false;
  }
}