Switch.adaptive constructor Null safety

const Switch.adaptive(
  1. {Key? key,
  2. required bool value,
  3. required ValueChanged<bool>? onChanged,
  4. Color? activeColor,
  5. Color? activeTrackColor,
  6. Color? inactiveThumbColor,
  7. Color? inactiveTrackColor,
  8. ImageProvider<Object>? activeThumbImage,
  9. ImageErrorListener? onActiveThumbImageError,
  10. ImageProvider<Object>? inactiveThumbImage,
  11. ImageErrorListener? onInactiveThumbImageError,
  12. MaterialTapTargetSize? materialTapTargetSize,
  13. MaterialStateProperty<Color?>? thumbColor,
  14. MaterialStateProperty<Color?>? trackColor,
  15. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  16. MouseCursor? mouseCursor,
  17. Color? focusColor,
  18. Color? hoverColor,
  19. MaterialStateProperty<Color?>? overlayColor,
  20. double? splashRadius,
  21. FocusNode? focusNode,
  22. bool autofocus = false}
)

Creates an adaptive Switch based on whether the target platform is iOS or macOS, following Material design's Cross-platform guidelines.

On iOS and macOS, this constructor creates a CupertinoSwitch, which has matching functionality and presentation as Material switches, and are the graphics expected on iOS. On other platforms, this creates a Material design Switch.

If a CupertinoSwitch is created, the following parameters are ignored: activeTrackColor, inactiveThumbColor, inactiveTrackColor, activeThumbImage, onActiveThumbImageError, inactiveThumbImage, onInactiveThumbImageError, materialTapTargetSize.

The target platform is based on the current Theme: ThemeData.platform.

Implementation

const Switch.adaptive({
  super.key,
  required this.value,
  required this.onChanged,
  this.activeColor,
  this.activeTrackColor,
  this.inactiveThumbColor,
  this.inactiveTrackColor,
  this.activeThumbImage,
  this.onActiveThumbImageError,
  this.inactiveThumbImage,
  this.onInactiveThumbImageError,
  this.materialTapTargetSize,
  this.thumbColor,
  this.trackColor,
  this.dragStartBehavior = DragStartBehavior.start,
  this.mouseCursor,
  this.focusColor,
  this.hoverColor,
  this.overlayColor,
  this.splashRadius,
  this.focusNode,
  this.autofocus = false,
})  : assert(autofocus != null),
      assert(activeThumbImage != null || onActiveThumbImageError == null),
      assert(inactiveThumbImage != null || onInactiveThumbImageError == null),
      _switchType = _SwitchType.adaptive;