isValidDateRange static method

bool isValidDateRange({
  1. required String fromDate,
  2. required String toDate,
})

Implementation

static bool isValidDateRange({required String fromDate, required String toDate}) {
  try {
    final dateFormat = DateFormat('MM-yyyy');
    final from = dateFormat.parseStrict(fromDate);
    final to = dateFormat.parseStrict(toDate);
    return to.isAfter(from) || to.isAtSameMomentAs(from);
  } catch (_) {
    return false;
  }
}