Switch
C2CSwitch is a customizable switch widget in Flutter. It offers a modern, adaptable switch control commonly used for toggling a certain setting on or off. It allows for custom colors, sizes, and has a disabled state.
Installation
cpub add c2c_switch
or
flutter pub add c2c_switch --hosted-url=https://pub.csp.scrum-dev.com
Example Usage
C2CSwitch(
value: true,
onChanged: (bool newValue) {
// Handle change
},
activeColor: Colors.blue,
thumbColor: Colors.white,
trackColor: Colors.grey,
// Additional customizations
);
Properties
| Property | Description | Type |
|---|---|---|
value | The current state of the switch (on/off). | bool |
disabled | Whether the switch is disabled or not. | bool |
onChanged | Callback called when the switch is toggled. | ValueChanged<bool>? |
activeColor | The color of the switch when it is on. | Color? |
trackColor | The color of the switch track. | Color? |
thumbColor | The color of the thumb (the circle part of the switch). | Color? |
dragStartBehavior | Behavior of the drag start with respect to handling gestures. | DragStartBehavior |
thumbSize | The size of the thumb. | double? |
width | The width of the switch. | double? |
height | The height of the switch. | double? |
disabledOpacity | The opacity of the switch when it is disabled. | double? |
label | Label text. It can be a String or a Widget. | dynamic |
labelTextStyle | Style for the label text. | TextStyle? |
description | Description text. It can be a String or a Widget. | dynamic |
descriptionTextStyle | Style for the description text. | TextStyle? |