CwSliders Documentation
Overview
The CwSliders
is a versatile slider component library that provides multiple factory constructors for creating different types of slider widgets. It offers extensive customization options for creating single sliders, range sliders, and slider tiles with various styling and interaction capabilities.
Factory Constructors
1. CwSliders.slider()
Creates a single-value slider with customizable appearance and behavior.
Parameters
minValue
: Minimum value of the slider (default:0.0
)maxValue
: Maximum value of the slider (default:100.0
)currentFirstValue
: Current value of the slideronChange
: Callback function triggered when the slider value changesactiveColor
: Color of the active portion of the slider trackinActiveColor
: Color of the inactive portion of the slider tracksliderThumb
: Custom widget to use as the slider thumbthumbRadius
: Radius of the slider thumbthumbColor
: Color of the slider thumbthumbBorderColor
: Border color of the slider thumbthumbBorderWidth
: Border width of the slider thumbshowThumbBorder
: Whether to show a border around the thumb (default:false
)divisions
: Number of discrete divisions for the slidertrackHeight
: Height of the slider trackshowValueIndicator
: Controls when to show the value indicatorvalueIndicatorShape
: Custom shape for the value indicatorvalueIndicatorBackGroundColor
: Background color of the value indicatorvalueIndicatorTextStyle
: Text style for the value indicatorsliderLabelPosition
: Position of the labels (default:SliderLabelPosition.none
)labelMin
: Custom text for the minimum value labellabelMax
: Custom text for the maximum value labellabelTextStyle
: Text style for the min/max labels
2. CwSliders.rangeSlider()
Creates a dual-handle range slider for selecting a range of values.
Additional Parameters
currentSecondValue
: Current value of the second handlevalueIndicatorShape
: Custom shape for the range slider value indicatorthumbShape
: Custom shape for the range slider thumbsonChange
: Callback function that receives aRangeValues
object when the range changes
3. CwSliders.sliderTile()
Creates a slider embedded within a customizable tile container.
Additional Parameters
slider
: The slider widget to displayprefix
: Widget to display before the slidersuffix
: Widget to display after the slidertitle
: Widget to display above the sliderbottom
: Widget to display below the slidertilePadding
: Padding around the tile contenttileColor
: Background color of the tiletileGradient
: Gradient background for the tiletileBorder
: Border styling for the tiletileBorderRadius
: Border radius of the tile
Usage Examples
1. Basic Single Slider
CwSliders.slider(
onChange: (value) => print('Slider value changed: $value'),
currentFirstValue: 25.0,
minValue: 0.0,
maxValue: 100.0,
activeColor: Colors.blue,
inActiveColor: Colors.grey,
)
2. Range Slider
CwSliders.rangeSlider(
onChange: (rangeValues) => print('Range values: $rangeValues'),
currentFirstValue: 20.0,
currentSecondValue: 80.0,
divisions: 10,
activeColor: Colors.green,
sliderLabelPosition: SliderLabelPosition.sides,
labelMin: "Min",
labelMax: "Max",
)
3. Slider Tile
CwSliders.sliderTile(
slider: Slider(
value: 50.0,
onChanged: (value) {},
min: 0.0,
max: 100.0,
),
prefix: Icon(Icons.volume_down),
suffix: Icon(Icons.volume_up),
title: Text('Volume Control'),
tileColor: Colors.grey.shade200,
tileBorderRadius: BorderRadius.circular(12),
)
Customization Options
The sliders provide extensive customization including:
- Thumb appearance (size, color, border)
- Track styling (height, active/inactive colors)
- Value indicators (visibility, styling, shape)
- Labels (position, text, styling)
- Divisions for discrete values
- Container styling for slider tiles
Source Code Repository
Find the full source code on GitHub: GitHub Repository