focusNode property

FocusNode focusNode

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:


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.


final FocusNode focusNode