TAnimatedToggleSwitch constructor

const TAnimatedToggleSwitch({
  1. Key? key,
  2. required bool current,
  3. FutureOr<void> onChanged(
    1. bool
    )?,
  4. Widget textBuilder(
    1. bool
    )?,
  5. Widget iconBuilder(
    1. bool
    )?,
  6. ToggleStyle styleBuilder(
    1. bool
    )?,
  7. double height = 40.0,
  8. double spacing = 50.0,
  9. bool loading = false,
  10. double borderWidth = 7.0,
  11. Color? activeColor,
  12. Color? inactiveColor,
  13. Color backgroundColor = Colors.white,
  14. Color borderColor = Colors.transparent,
  15. Size indicatorSize = const Size.fromWidth(25),
  16. List<BoxShadow> boxShadow = const [BoxShadow(color: Colors.black26, spreadRadius: 1, blurRadius: 2, offset: Offset(0, 1.5))],
})

A fully customizable animated toggle switch with dual states.

Developers can control:

  • State (current)
  • Text, icon, and style builders
  • Customizable spacing, height, border width, and indicator size
  • Loading state
  • Colors for active and inactive states

Example:

TAnimatedToggleSwitch(
  current: true,
  onChanged: (value) {
    print('Toggled to: $value');
  },
  activeColor: Colors.blue,
  inactiveColor: Colors.grey,
  spacing: 30.0,
  height: 50.0,
  borderWidth: 5.0,
)

Constructor for creating a fully customizable toggle switch.

current determines the toggle's state. onChanged is a callback triggered when the state changes. Use activeColor, inactiveColor, spacing, height, and borderWidth to control styles.

Implementation

const TAnimatedToggleSwitch({
  super.key,
  required this.current,
  this.onChanged,
  this.textBuilder,
  this.iconBuilder,
  this.styleBuilder,
  this.height = 40.0,
  this.spacing = 50.0,
  this.loading = false,
  this.borderWidth = 7.0,
  this.activeColor,
  this.inactiveColor,
  this.backgroundColor = Colors.white,
  this.borderColor = Colors.transparent,
  this.indicatorSize = const Size.fromWidth(25),
  this.boxShadow = const [
    BoxShadow(
      color: Colors.black26,
      spreadRadius: 1,
      blurRadius: 2,
      offset: Offset(0, 1.5),
    )
  ],
});