charIgnoringCase function Null safety

Parser<String> charIgnoringCase(
  1. String char,
  2. [String? message]
)

Returns a parser that accepts a case-insensitive specific character only.

Implementation

Parser<String> charIgnoringCase(String char, [String? message]) {
  final lowerCase = toCharCode(char.toLowerCase());
  final upperCase = toCharCode(char.toUpperCase());
  return CharacterParser(
      optimizedRanges([
        RangeCharPredicate(lowerCase, lowerCase),
        RangeCharPredicate(upperCase, upperCase),
      ]),
      message ?? '"${toReadableString(char)}" (case-insensitive) expected');
}