isDateRange function

bool isDateRange(
  1. String? str, [
  2. dynamic min,
  3. dynamic max
])

Implementation

bool isDateRange(String? str, [min, max]) {
  if (min == null) {
    min = DateTime.now();
  } else if (isDate(min as String)) {
    min = DateTime.parse(min);
  } else {
    return false;
  }

  if (max == null) {
    max = DateTime.now();
  } else if (isDate(max as String)) {
    max = DateTime.parse(max);
  } else {
    return false;
  }

  DateTime str_date;
  try {
    str_date = DateTime.parse(str!);
  } catch (e) {
    return false;
  }

  return str_date.isAfter(min as DateTime) && str_date.isBefore(max as DateTime);
}