Focus constructor Null safety

const Focus(
  1. {Key? key,
  2. required Widget child,
  3. FocusNode? focusNode,
  4. bool autofocus = false,
  5. ValueChanged<bool>? onFocusChange,
  6. FocusOnKeyEventCallback? onKeyEvent,
  7. FocusOnKeyCallback? onKey,
  8. bool? canRequestFocus,
  9. bool? skipTraversal,
  10. bool? descendantsAreFocusable,
  11. bool? descendantsAreTraversable,
  12. bool includeSemantics = true,
  13. String? debugLabel}
)

Creates a widget that manages a FocusNode.

The child argument is required and must not be null.

The autofocus argument must not be null.

Implementation

const Focus({
  super.key,
  required this.child,
  this.focusNode,
  this.autofocus = false,
  this.onFocusChange,
  FocusOnKeyEventCallback? onKeyEvent,
  FocusOnKeyCallback? onKey,
  bool? canRequestFocus,
  bool? skipTraversal,
  bool? descendantsAreFocusable,
  bool? descendantsAreTraversable,
  this.includeSemantics = true,
  String? debugLabel,
})  : _onKeyEvent = onKeyEvent,
      _onKey = onKey,
      _canRequestFocus = canRequestFocus,
      _skipTraversal = skipTraversal,
      _descendantsAreFocusable = descendantsAreFocusable,
      _descendantsAreTraversable = descendantsAreTraversable,
      _debugLabel = debugLabel,
      assert(child != null),
      assert(autofocus != null),
      assert(includeSemantics != null);