enclosingScope property

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 {
  final FocusScopeNode? enclosingScope = _enclosingScope ??= parent?.nearestScope;
  assert(enclosingScope == parent?.nearestScope, '$this has invalid scope cache: $_enclosingScope != ${parent?.nearestScope}');
  return enclosingScope;
}