isBefore function

bool isBefore(
  1. String? str, [
  2. dynamic date
])

check if the string is a date that's before the specified date

If date is not passed, it defaults to now.

Implementation

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

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

  return str_date.isBefore(date as DateTime);
}