TIconToggleSwitch<T> constructor
const
TIconToggleSwitch<T> ({
- Key? key,
- required T current,
- required List<
T> options, - required List<
IconData> icons, - void onChanged(
- T
- double spacing = 14.0,
- double height = 42.0,
- double iconSize = 24.0,
- double borderWidth = 7,
- double indicatorWidth = 28.0,
- Color? activeColor,
- Color? inactiveColor = Colors.grey,
- Color backgroundColor = Colors.white,
- Color borderColor = Colors.transparent,
- bool loading = false,
- List<
BoxShadow> boxShadow = const [BoxShadow(color: Colors.black12, spreadRadius: 1, blurRadius: 2, offset: Offset(0, 1.5))], - ToggleStyle styleBuilder(
- T
A customizable rolling icon toggle switch.
Features:
- Allows customization of dimensions, spacing, and styles.
- Handles a list of options and their corresponding icons.
- Optional loading state and dynamic style customization.
Example Usage:
TIconToggleSwitch<int>(
current: 1,
options: [0, 1],
icons: [Icons.light_mode, Icons.dark_mode],
onChanged: (value) {
print('Selected: $value');
},
spacing: 20.0,
height: 50.0,
)
Constructs a customizable toggle switch with icons.
current
is the currently selected value.
options
is the list of selectable values.
icons
provides the icons corresponding to the values.
Implementation
const TIconToggleSwitch({
super.key,
required this.current,
required this.options,
required this.icons,
this.onChanged,
this.spacing = 14.0,
this.height = 42.0,
this.iconSize = 24.0,
this.borderWidth = 7,
this.indicatorWidth = 28.0,
this.activeColor,
this.inactiveColor = Colors.grey,
this.backgroundColor = Colors.white,
this.borderColor = Colors.transparent,
this.loading = false,
this.boxShadow = const [
BoxShadow(
color: Colors.black12,
spreadRadius: 1,
blurRadius: 2,
offset: Offset(0, 1.5),
),
],
this.styleBuilder,
});