SwitchState.adaptive constructor

const SwitchState.adaptive({
  1. Key? key,
  2. required bool value,
  3. 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,
  23. ValueCallback<BuildContext>? initState,
  24. ValueCallback<BuildContext>? dispose,
  25. ValueCallback<BuildContext>? didChangeDependencies,
  26. ValueCallback<BuildContext>? didUpdateWidget,
  27. SwitchStateChanged? onWaitChanged,
})

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 SwitchState.adaptive({
  super.key,
  required this.value,
  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,
  this.initState,
  this.dispose,
  this.didChangeDependencies,
  this.didUpdateWidget,
  this.onWaitChanged,
}) : _switchType = _SwitchType.adaptive;