isControlCharacter method

bool isControlCharacter (
  1. String label
)

Returns true if the given label represents a Unicode control character.

Examples of control characters are characters like "U+000A LINE FEED (LF)" or "U+001B ESCAPE (ESC)".

See en.wikipedia.org/wiki/Unicode_control_characters for more information.

Used by RawKeyEvent subclasses to help construct IDs.

Implementation

static bool isControlCharacter(String label) {
  if (label.length > 1) {
    return false;
  }
  final int codeUnit = label.codeUnitAt(0);
  return (codeUnit <= 0x1f && codeUnit >= 0x00) || (codeUnit >= 0x7f && codeUnit <= 0x9f);
}