ancestors property

Iterable<FocusNode> ancestors

An Iterable over the ancestors of this node.

Iterates the ancestors of this node starting at the parent and iterating over successively more remote ancestors of this node, ending at the root FocusScopeNode (FocusManager.rootScope).


Iterable<FocusNode> get ancestors {
  if (_ancestors == null) {
    final List<FocusNode> result = <FocusNode>[];
    FocusNode? parent = _parent;
    while (parent != null) {
      parent = parent._parent;
    _ancestors = result;
  return _ancestors!;