tryParse static method

Date? tryParse(
  1. String dateStr, {
  2. String? format,
  3. bool utc = false,
})

Constructs a new DateTime instance based on dateStr.

Works like parse except that this function returns null where parse would throw a FormatException.

Implementation

static Date? tryParse(
  String dateStr, {
  String? format,
  bool utc = false,
}) {
  try {
    return parse(
      dateStr,
      format: format,
      utc: utc,
    );
  } on FormatException {
    return null;
  }
}