RothkoToggle constructor

RothkoToggle({
  1. Key? key,
  2. required bool value,
  3. required ValueChanged<bool> onToggle,
  4. Color activeColor = RothkoColor.kPrimaryBase,
  5. Color inactiveColor = RothkoColor.kLightNeutralDarken2,
  6. Color toggleColor = RothkoColor.kLightNeutralLighten2,
  7. Color? activeToggleColor,
  8. Color? inactiveToggleColor,
  9. double width = 55.0,
  10. double height = 32.0,
  11. double toggleSize = 25.0,
  12. double valueFontSize = 16.0,
  13. double borderRadius = 20.0,
  14. double padding = 4.0,
  15. bool showOnOff = false,
  16. String? inactiveText,
  17. FontWeight? activeTextFontWeight,
  18. FontWeight? inactiveTextFontWeight,
  19. BoxBorder? switchBorder,
  20. BoxBorder? activeSwitchBorder,
  21. BoxBorder? inactiveSwitchBorder,
  22. BoxBorder? toggleBorder,
  23. BoxBorder? activeToggleBorder,
  24. BoxBorder? inactiveToggleBorder,
  25. Widget? activeIcon,
  26. Widget? inactiveIcon,
  27. Duration duration = const Duration(milliseconds: 200),
  28. bool disabled = false,
  29. bool? isReadOnly,
})

Creates a material design switch.

The following arguments are required:

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

Implementation

RothkoToggle({
  Key? key,
  required this.value,
  required this.onToggle,
  this.activeColor = RothkoColor.kPrimaryBase,
  this.inactiveColor = RothkoColor.kLightNeutralDarken2,
  this.toggleColor = RothkoColor.kLightNeutralLighten2,
  this.activeToggleColor,
  this.inactiveToggleColor,
  this.width = 55.0,
  this.height = 32.0,
  this.toggleSize = 25.0,
  this.valueFontSize = 16.0,
  this.borderRadius = 20.0,
  this.padding = 4.0,
  this.showOnOff = false,
  this.inactiveText,
  this.activeTextFontWeight,
  this.inactiveTextFontWeight,
  this.switchBorder,
  this.activeSwitchBorder,
  this.inactiveSwitchBorder,
  this.toggleBorder,
  this.activeToggleBorder,
  this.inactiveToggleBorder,
  this.activeIcon,
  this.inactiveIcon,
  this.duration = const Duration(milliseconds: 200),
  this.disabled = false,
  this.isReadOnly,
})  : assert(
          (switchBorder == null || activeSwitchBorder == null) &&
              (switchBorder == null || inactiveSwitchBorder == null),
          'Cannot provide switchBorder when an activeSwitchBorder or inactiveSwitchBorder was given\n'
          'To give the switch a border, use "activeSwitchBorder: border" or "inactiveSwitchBorder: border".'),
      assert(
          (toggleBorder == null || activeToggleBorder == null) &&
              (toggleBorder == null || inactiveToggleBorder == null),
          'Cannot provide toggleBorder when an activeToggleBorder or inactiveToggleBorder was given\n'
          'To give the toggle a border, use "activeToggleBorder: color" or "inactiveToggleBorder: color".'),
      super(key: key);