FocusNode constructor

  1. {String? debugLabel,
  2. FocusOnKeyCallback? onKey,
  3. FocusOnKeyEventCallback? onKeyEvent,
  4. bool skipTraversal = false,
  5. bool canRequestFocus = true,
  6. bool descendantsAreFocusable = true,
  7. 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.


  String? debugLabel,
  bool skipTraversal = false,
  bool canRequestFocus = true,
  bool descendantsAreFocusable = true,
  bool descendantsAreTraversable = true,
})  : _skipTraversal = skipTraversal,
      _canRequestFocus = canRequestFocus,
      _descendantsAreFocusable = descendantsAreFocusable,
      _descendantsAreTraversable = descendantsAreTraversable {
  // Set it via the setter so that it does nothing on release builds.
  this.debugLabel = debugLabel;