string function Null safety

Parser<String> string(
  1. String element,
  2. [String? message]
)

Returns a parser that accepts the string element.

For example, string('foo') succeeds and consumes the input string'foo'. Fails for any other input.

Implementation

Parser<String> string(String element, [String? message]) => predicate(
    element.length,
    (each) => element == each,
    message ?? '"$element" expected');