ControlledCheckbox constructor

const ControlledCheckbox({
  1. Key? key,
  2. CheckboxController? controller,
  3. CheckboxState initialValue = CheckboxState.unchecked,
  4. ValueChanged<CheckboxState>? onChanged,
  5. bool enabled = true,
  6. Widget? leading,
  7. Widget? trailing,
  8. bool tristate = false,
  9. double? size,
  10. double? gap,
  11. Color? activeColor,
  12. Color? borderColor,
  13. 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 controller
  • initialValue (CheckboxState, default: unchecked): starting state when no controller
  • onChanged (ValueChanged
  • enabled (bool, default: true): whether checkbox is interactive
  • leading (Widget?, optional): widget displayed before checkbox
  • trailing (Widget?, optional): widget displayed after checkbox
  • tristate (bool, default: false): whether to support indeterminate state
  • size (double?, optional): override checkbox square size
  • gap (double?, optional): override spacing around checkbox
  • activeColor (Color?, optional): override checked state color
  • borderColor (Color?, optional): override border color
  • borderRadius (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,
});