canRequestFocus property

bool canRequestFocus
inherited

If true, this focus node may request the primary focus.

Defaults to true. Set to false if you want this node to do nothing when requestFocus is called on it.

If set to false on a FocusScopeNode, will cause all of the children of the scope node to not be focusable.

If set to false on a FocusNode, it will not affect the children of the node.

The hasFocus member can still return true if this node is the ancestor of a node with primary focus.

This is different than skipTraversal because skipTraversal still allows the node to be focused, just not traversed to via the FocusTraversalPolicy

Setting canRequestFocus to false implies that the node will also be skipped for traversal purposes.

See also:

  • FocusTraversalGroup, a widget used to group together and configure the focus traversal policy for a widget subtree.
  • FocusTraversalPolicy, a class that can be extended to describe a traversal policy.

Implementation

bool get canRequestFocus {
  final FocusScopeNode scope = enclosingScope;
  return _canRequestFocus && (scope == null || scope.canRequestFocus);
}
void canRequestFocus= (bool value)
@mustCallSuper, inherited

Implementation

@mustCallSuper
set canRequestFocus(bool value) {
  if (value != _canRequestFocus) {
    if (!value) {
      unfocus(disposition: UnfocusDisposition.previouslyFocusedChild);
    }
    _canRequestFocus = value;
    _manager?._markPropertiesChanged(this);
  }
}