ControlledCheckbox constructor
const
ControlledCheckbox({
- Key? key,
- CheckboxController? controller,
- CheckboxState initialValue = CheckboxState.unchecked,
- ValueChanged<
CheckboxState> ? onChanged, - bool enabled = true,
- Widget? leading,
- Widget? trailing,
- bool tristate = false,
- double? size,
- double? gap,
- Color? activeColor,
- Color? borderColor,
- BorderRadiusGeometry? borderRadius,
Creates a ControlledCheckbox.
Either controller or onChanged should be provided for interactivity.
The widget supports both controller-based and callback-based state management
patterns depending on application architecture needs.
Parameters:
controller(CheckboxController?, optional): external state controllerinitialValue(CheckboxState, default: unchecked): starting state when no controlleronChanged(ValueChangedenabled(bool, default: true): whether checkbox is interactiveleading(Widget?, optional): widget displayed before checkboxtrailing(Widget?, optional): widget displayed after checkboxtristate(bool, default: false): whether to support indeterminate statesize(double?, optional): override checkbox square sizegap(double?, optional): override spacing around checkboxactiveColor(Color?, optional): override checked state colorborderColor(Color?, optional): override border colorborderRadius(BorderRadiusGeometry?, optional): override corner radius
Example:
ControlledCheckbox(
controller: controller,
tristate: true,
leading: Icon(Icons.star),
trailing: Text('Favorite'),
)
Implementation
const ControlledCheckbox({
super.key,
this.controller,
this.initialValue = CheckboxState.unchecked,
this.onChanged,
this.enabled = true,
this.leading,
this.trailing,
this.tristate = false,
this.size,
this.gap,
this.activeColor,
this.borderColor,
this.borderRadius,
});