TIconToggleSwitch<T> constructor

const TIconToggleSwitch<T>({
  1. Key? key,
  2. required T current,
  3. required List<T> options,
  4. required List<IconData> icons,
  5. void onChanged(
    1. T
    )?,
  6. double spacing = 14.0,
  7. double height = 42.0,
  8. double iconSize = 24.0,
  9. double borderWidth = 7,
  10. double indicatorWidth = 28.0,
  11. Color? activeColor,
  12. Color? inactiveColor = Colors.grey,
  13. Color backgroundColor = Colors.white,
  14. Color borderColor = Colors.transparent,
  15. bool loading = false,
  16. List<BoxShadow> boxShadow = const [BoxShadow(color: Colors.black12, spreadRadius: 1, blurRadius: 2, offset: Offset(0, 1.5))],
  17. ToggleStyle styleBuilder(
    1. 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,
});