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. Does not affect the children of this node, and hasFocus 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:

  • DefaultFocusTraversal, a widget that sets the traversal policy for its descendants.
  • FocusTraversalPolicy, a class that can be extended to describe a traversal policy.

Implementation

bool get canRequestFocus => _canRequestFocus;
void canRequestFocus= (bool value)
inherited

Implementation

set canRequestFocus(bool value) {
  if (value != _canRequestFocus) {
    _canRequestFocus = value;
    if (!_canRequestFocus) {
      unfocus();
    }
    _notify();
  }
}