parse method

DateTime? Function(String) parse(
  1. String specifier, {
  2. bool isUtc = false,
})

Returns a new parser for the given string specifier.

timeParse("%b %d");

The specifier string may contain the same directives as TimeFormatLocale.format. The %d and %e directives are considered equivalent for parsing.

The returned function parses a specified string, returning the corresponding date or null if the string could not be parsed according to this format’s specifier. Parsing is strict: if the specified string does not exactly match the associated specifier, this method returns null. For example, if the associated specifier is %Y-%m-%dT%H:%M:%SZ, then the string "2011-07-01T19:15:28Z" will be parsed as expected, but "2011-07-01T19:15:28", "2011-07-01 19:15:28" and "2011-07-01" will return null. (Note that the literal Z here is different from the time zone offset directive %Z.) If a more flexible parser is desired, try multiple formats sequentially until one returns non-null.

Implementation

DateTime? Function(String) parse(String specifier, {bool isUtc = false}) {
  return _newParse(specifier, isUtc);
}