tryParse method
Given user input, attempt to parse the inputString
into the anticipated
format, treating it as being in the local timezone.
If inputString
does not match our format, returns null
.
This will accept dates whose values are not strictly valid, or strings
with additional characters (including whitespace) after a valid date. For
stricter parsing, use tryParseStrict.
Implementation
DateTime? tryParse(String inputString, [bool utc = false]) {
try {
return parse(inputString, utc);
} on FormatException {
return null;
}
}