enclosingScope property Null safety

FocusScopeNode? enclosingScope

Returns the nearest enclosing scope node above this node, or null if the node has not yet be added to the focus tree.

If this node is itself a scope, this will only return ancestors of this scope.

Use nearestScope to start at this node instead of above it.

Implementation

FocusScopeNode? get enclosingScope {
  for (final FocusNode node in ancestors) {
    if (node is FocusScopeNode) {
      return node;
    }
  }
  return null;
}