isPastMonthYear static method

bool isPastMonthYear({
  1. required String input,
  2. String? dateFormat,
})

Implementation

static bool isPastMonthYear({required String input,String? dateFormat}) {
  try {
    final inputDate = DateFormat(dateFormat??'MM-yyyy').parseStrict(input);
    final now = DateTime(DateTime.now().year, DateTime.now().month);
    return inputDate.isBefore(now) || inputDate.isAtSameMomentAs(now);
  } catch (_) {
    return false;
  }
}