tryParse static method

Date? tryParse(
  1. String formattedDate
)

Tries to parse a formatted date.

Accepts the same formats as DateTime.parse, and throws away the time. Returns null if the input is not accepted.

Implementation

static Date? tryParse(String formattedDate) {
  final time = DateTime.tryParse(formattedDate);
  if (time == null) return null;
  return Date.from(time);
}