Skip to main content

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

PropertyDescriptionType
valueThe current state of the switch (on/off).bool
disabledWhether the switch is disabled or not.bool
onChangedCallback called when the switch is toggled.ValueChanged<bool>?
activeColorThe color of the switch when it is on.Color?
trackColorThe color of the switch track.Color?
thumbColorThe color of the thumb (the circle part of the switch).Color?
dragStartBehaviorBehavior of the drag start with respect to handling gestures.DragStartBehavior
thumbSizeThe size of the thumb.double?
widthThe width of the switch.double?
heightThe height of the switch.double?
disabledOpacityThe opacity of the switch when it is disabled.double?
labelLabel text. It can be a String or a Widget.dynamic
labelTextStyleStyle for the label text.TextStyle?
descriptionDescription text. It can be a String or a Widget.dynamic
descriptionTextStyleStyle for the description text.TextStyle?