FocusNode constructor

FocusNode({
  1. String? debugLabel,
  2. @Deprecated('Use onKeyEvent instead. ' 'This feature was deprecated after v3.18.0-2.0.pre.') 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.

To receive key events that focuses on this node, pass a listener to onKeyEvent.

Implementation

FocusNode({
  String? debugLabel,
  @Deprecated(
    'Use onKeyEvent instead. '
    'This feature was deprecated after v3.18.0-2.0.pre.',
  )
  this.onKey,
  this.onKeyEvent,
  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;

  if (kFlutterMemoryAllocationsEnabled) {
    ChangeNotifier.maybeDispatchObjectCreation(this);
  }
}