isValidDateRange static method

bool isValidDateRange(
  1. String fromDate,
  2. String toDate
)

Implementation

static bool isValidDateRange(String fromDate, 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;
  }
}