descendantsAreFocusable property Null safety
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.
If a descendant node loses focus when this value is changed, the focus will move to the scope enclosing this node.
See also:
- ExcludeFocus, a widget that uses this property to conditionally exclude focus for a subtree.
- descendantsAreTraversable, which makes this widget's descendants untraversable.
- ExcludeFocusTraversal, a widget that conditionally excludes focus traversal 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;
mustCallSuper">@mustCallSuper
Implementation
@mustCallSuper
set descendantsAreFocusable(bool value) {
if (value == _descendantsAreFocusable) {
return;
}
// Set _descendantsAreFocusable before unfocusing, so the scope won't try
// and focus any of the children here again if it is false.
_descendantsAreFocusable = value;
if (!value && hasFocus) {
unfocus(disposition: UnfocusDisposition.previouslyFocusedChild);
}
_manager?._markPropertiesChanged(this);
}