FlutterSwitch constructor
const
FlutterSwitch({
- Key? key,
- required bool value,
- required ValueChanged<
bool> onToggle, - Color activeColor = Colors.blue,
- Color inactiveColor = Colors.grey,
- Color activeTextColor = Colors.white70,
- Color inactiveTextColor = Colors.white70,
- Color toggleColor = Colors.white,
- Color? activeToggleColor,
- Color? inactiveToggleColor,
- double width = 70.0,
- double height = 35.0,
- double toggleSize = 25.0,
- double valueFontSize = 16.0,
- double borderRadius = 20.0,
- double padding = 4.0,
- bool showOnOff = false,
- String? activeText,
- String? inactiveText,
- FontWeight? activeTextFontWeight,
- FontWeight? inactiveTextFontWeight,
- BoxBorder? switchBorder,
- BoxBorder? activeSwitchBorder,
- BoxBorder? inactiveSwitchBorder,
- BoxBorder? toggleBorder,
- BoxBorder? activeToggleBorder,
- BoxBorder? inactiveToggleBorder,
- Widget? activeIcon,
- Widget? inactiveIcon,
- Duration duration = const Duration(milliseconds: 200),
- bool disabled = false,
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
const FlutterSwitch({
Key? key,
required this.value,
required this.onToggle,
this.activeColor = Colors.blue,
this.inactiveColor = Colors.grey,
this.activeTextColor = Colors.white70,
this.inactiveTextColor = Colors.white70,
this.toggleColor = Colors.white,
this.activeToggleColor,
this.inactiveToggleColor,
this.width = 70.0,
this.height = 35.0,
this.toggleSize = 25.0,
this.valueFontSize = 16.0,
this.borderRadius = 20.0,
this.padding = 4.0,
this.showOnOff = false,
this.activeText,
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,
}) : 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);