Focus constructor Null safety

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