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. DragStartBehavior dragStartBehavior: DragStartBehavior.start,
  14. MouseCursor? mouseCursor,
  15. Color? focusColor,
  16. Color? hoverColor,
  17. FocusNode? focusNode,
  18. bool autofocus: false}
)

Creates a CupertinoSwitch if the target platform is iOS, creates a material design switch otherwise.

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({
  Key? 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.dragStartBehavior = DragStartBehavior.start,
  this.mouseCursor,
  this.focusColor,
  this.hoverColor,
  this.focusNode,
  this.autofocus = false,
})  : assert(autofocus != null),
      assert(activeThumbImage != null || onActiveThumbImageError == null),
      assert(inactiveThumbImage != null || onInactiveThumbImageError == null),
      _switchType = _SwitchType.adaptive,
      super(key: key);