debugDescribeKeys method

  1. @override
String debugDescribeKeys()
override

Returns a description of the key set that is short and readable.

Intended to be used in debug mode for logging purposes.

Implementation

@override
String debugDescribeKeys() {
  final List<LogicalKeyboardKey> sortedKeys = keys.toList()
    ..sort((LogicalKeyboardKey a, LogicalKeyboardKey b) {
        // Put the modifiers first. If it has a synonym, then it's something
        // like shiftLeft, altRight, etc.
        final bool aIsModifier = a.synonyms.isNotEmpty || _modifiers.contains(a);
        final bool bIsModifier = b.synonyms.isNotEmpty || _modifiers.contains(b);
        if (aIsModifier && !bIsModifier) {
          return -1;
        } else if (bIsModifier && !aIsModifier) {
          return 1;
        }
        return a.debugName!.compareTo(b.debugName!);
      });
  return sortedKeys.map<String>((LogicalKeyboardKey key) => key.debugName.toString()).join(' + ');
}