FocusNode constructor Null safety
- {String? debugLabel,
- FocusOnKeyCallback? onKey,
- FocusOnKeyEventCallback? onKeyEvent,
- bool skipTraversal = false,
- bool canRequestFocus = true,
- bool descendantsAreFocusable = true,
- bool descendantsAreTraversable = true}
Creates a focus node.
The debugLabel
is ignored on release builds.
The skipTraversal
, descendantsAreFocusable
, and canRequestFocus
arguments must not be null.
To receive key events that focuses on this node, pass a listener to onKeyEvent
.
The onKey
is a legacy API based on RawKeyEvent and will be deprecated
in the future.
Implementation
FocusNode({
String? debugLabel,
this.onKey,
this.onKeyEvent,
bool skipTraversal = false,
bool canRequestFocus = true,
bool descendantsAreFocusable = true,
bool descendantsAreTraversable = true,
}) : assert(skipTraversal != null),
assert(canRequestFocus != null),
assert(descendantsAreFocusable != null),
_skipTraversal = skipTraversal,
_canRequestFocus = canRequestFocus,
_descendantsAreFocusable = descendantsAreFocusable,
_descendantsAreTraversable = descendantsAreTraversable {
// Set it via the setter so that it does nothing on release builds.
this.debugLabel = debugLabel;
}