Parsing
parse and tryParse read strings written in the same pattern syntax as format, including do ordinals and [literal] or 'literal' text, so formatting and parsing round-trip.
parse / tryParse
strict: truerejects out-of-range values such as February 30.utc: truereturns a UTCDateTime.tryParsereturnsnullinstead of throwing aFormatException.- Input is read in the formatter's locale: month and weekday names must be in that language. The sample input follows the locale selected in the dark bar.
LOADING…
⚙ TRY IT
⚡ OUTPUT
final formatter = FlutterDateFormatter('do MMMM yyyy', 'en');
formatter.parse('');
formatter.tryParse(''); // null instead of throwing
Ordinals
For do, the parser tries each ordinal suffix of the locale and keeps the result whose day actually takes that suffix, so 2st March is rejected.