focusNode property
Defines the keyboard focus for this widget.
The focusNode is a long-lived object that's typically managed by a StatefulWidget parent. See FocusNode for more information.
To give the keyboard 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:
myFocusNode.addListener(() { print(myFocusNode.hasFocus); });
If null, this widget will create its own FocusNode.
Keyboard
Requesting the focus will typically cause the keyboard to be shown if it's not showing already.
On Android, the user can hide the keyboard - without changing the focus - with the system back button. They can restore the keyboard's visibility by tapping on a text field. The user might hide the keyboard and switch to a physical keyboard, or they might just need to get it out of the way for a moment, to expose something it's obscuring. In this case requesting the focus again will not cause the focus to change, and will not make the keyboard visible.
If this is non-null, the behaviour of requestFocusOnTap is overridden by the FocusNode.canRequestFocus property.
Implementation
final FocusNode? focusNode;