focusNode property Null safety

FocusNode? focusNode
final

Defines the focus for this widget.

Text is only selectable when widget is focused.

The focusNode is a long-lived object that's typically managed by a StatefulWidget parent. See FocusNode for more information.

To give the focus to this widget, provide a focusNode and then use the current FocusScope to request the focus:

FocusScope.of(context).requestFocus(myFocusNode);

This happens automatically when the widget is tapped.

To be notified when the widget gains or loses the focus, add a listener to the focusNode:

focusNode.addListener(() { print(myFocusNode.hasFocus); });

If null, this widget will create its own FocusNode with FocusNode.skipTraversal parameter set to true, which causes the widget to be skipped over during focus traversal.

Implementation

final FocusNode? focusNode;