ControlledToggle constructor
const
ControlledToggle({
- Key? key,
- ToggleController? controller,
- bool? initialValue,
- ValueChanged<
bool> ? onChanged, - bool enabled = true,
- required Widget child,
- ButtonStyle style = const ButtonStyle.ghost(),
Creates a ControlledToggle widget.
Parameters:
controller
(ToggleController?, optional): External state controller.initialValue
(bool?, optional): Initial state for uncontrolled mode.onChanged
(ValueChangedenabled
(bool, default: true): Whether the toggle is interactive.child
(Widget, required): Content to display in the toggle button.style
(ButtonStyle, default: ButtonStyle.ghost()): Visual styling.
Example:
ControlledToggle(
initialValue: false,
onChanged: (value) => print('Toggled: $value'),
enabled: true,
style: ButtonStyle.secondary(),
child: Text('Toggle Me'),
);
Implementation
const ControlledToggle({
super.key,
this.controller,
this.initialValue,
this.onChanged,
this.enabled = true,
required this.child,
this.style = const ButtonStyle.ghost(),
});