bubbleKeyEvent method

bool bubbleKeyEvent(
  1. KeyEvent event
)

Bubbles the event up the parent chain starting from the focused leaf.

Implementation

bool bubbleKeyEvent(KeyEvent event) {
  FocusNode? current = findFocusedLeaf() ?? this;
  while (current != null) {
    if (current.onKeyEvent != null && current.onKeyEvent!(event)) {
      return true; // Consumed
    }
    if (current is FocusScopeNode && current.children.isNotEmpty) {
      if (event.type == KeyType.tab ||
          event.key == '\t' ||
          event.key == 'backtab') {
        final isShift =
            event.modifiers.contains(ev.Modifier.shift) ||
            event.key == 'backtab';
        if (isShift) {
          current.previousFocus();
        } else {
          current.nextFocus();
        }
        return true; // Consumed
      }
    }
    current = current.parent;
  }
  return false; // Propagates to system fallback
}