descendantsAreFocusable property

bool descendantsAreFocusable

If false, will disable focus for all of this node's descendants.

Defaults to true. Does not affect focusability of this node: for that, use canRequestFocus.

If any descendants are focused when this is set to false, they will be unfocused. When descendantsAreFocusable is set to true again, they will not be refocused, although they will be able to accept focus again.

Does not affect the value of canRequestFocus on the descendants.

See also:

  • ExcludeFocus, a widget that uses this property to conditionally exclude focus for a subtree.
  • Focus, a widget that exposes this setting as a parameter.
  • FocusTraversalGroup, a widget used to group together and configure the focus traversal policy for a widget subtree that also has an descendantsAreFocusable parameter that prevents its children from being focused.

Implementation

bool get descendantsAreFocusable => _descendantsAreFocusable;
void descendantsAreFocusable= (bool value)
@mustCallSuper

Implementation

@mustCallSuper
set descendantsAreFocusable(bool value) {
  if (value == _descendantsAreFocusable) {
    return;
  }
  if (!value && hasFocus) {
    for (final FocusNode child in children) {
      child.unfocus(disposition: UnfocusDisposition.previouslyFocusedChild);
    }
  }
  _descendantsAreFocusable = value;
  _manager?._markPropertiesChanged(this);
}