tryParse static method

LocalDate? tryParse(
  1. String formattedString
)

Creates a new LocalDate from a formattedString, or null if the string is not a valid date.

Expects a string in the format YYYY-MM-DD, without any timezone.

Implementation

static LocalDate? tryParse(String formattedString) {
  try {
    return parse(formattedString);
  } on FormatException {
    return null;
  }
}