stringIgnoreCase function

  1. @useResult
Parser<String> stringIgnoreCase(
  1. String element, [
  2. String? message
])

Returns a parser that accepts the string element ignoring the case.

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

Implementation

@useResult
Parser<String> stringIgnoreCase(String element, [String? message]) {
  final lowerElement = element.toLowerCase();
  return predicate(element.length, (each) => lowerElement == each.toLowerCase(),
      message ?? '"$element" (case-insensitive) expected');
}