OneUISwitch constructor

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

Creates a OneUI design switch.

The switch itself does not maintain any state. Instead, when the state of the switch changes, the widget calls the onChanged callback. Most widgets that use a switch will listen for the onChanged callback and rebuild the switch with a new value to update the visual appearance of the switch.

The following arguments are required:

  • value determines whether this switch is on or off.
  • onChanged is called when the user toggles the switch on or off.

Implementation

const OneUISwitch({
  Key? key,
  required this.value,
  required this.onChanged,
  this.useOneUIColor = false,
  this.activeColor,
  this.disabledThumbColor,
  this.activeThumbImage,
  this.onActiveThumbImageError,
  this.inactiveThumbImage,
  this.onInactiveThumbImageError,
  this.thumbColor,
  this.trackColor,
  this.thumbBorderColor,
  this.trackBorderColor,
  this.materialTapTargetSize,
  this.dragStartBehavior = DragStartBehavior.start,
  this.mouseCursor,
  this.focusColor,
  this.hoverColor,
  this.overlayColor,
  this.splashRadius,
  this.focusNode,
  this.autofocus = false,
})  : assert(activeThumbImage != null || onActiveThumbImageError == null),
      assert(inactiveThumbImage != null || onInactiveThumbImageError == null),
      super(key: key);