TAnimatedToggleSwitch constructor
const
TAnimatedToggleSwitch({
- Key? key,
- required bool current,
- FutureOr<
void> onChanged()?, - Widget textBuilder()?,
- Widget iconBuilder()?,
- ToggleStyle styleBuilder()?,
- double height = 40.0,
- double spacing = 50.0,
- bool loading = false,
- double borderWidth = 7.0,
- Color? activeColor,
- Color? inactiveColor,
- Color backgroundColor = Colors.white,
- Color borderColor = Colors.transparent,
- Size indicatorSize = const Size.fromWidth(25),
- 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),
)
],
});