ControlledMultipleChoice<T> constructor

const ControlledMultipleChoice<T>({
  1. Key? key,
  2. MultipleChoiceController<T>? controller,
  3. ValueChanged<T?>? onChanged,
  4. T? initialValue,
  5. bool enabled = true,
  6. bool? allowUnselect,
  7. required Widget child,
})

Creates a ControlledMultipleChoice.

Either controller or initialValue should be provided to establish the initial selection state. The child should contain choice items that integrate with the single selection system.

Parameters:

  • controller (MultipleChoiceController
  • initialValue (T?, optional): Initial selection when no controller provided
  • onChanged (ValueChanged<T?>?, optional): Callback for selection changes
  • enabled (bool, default: true): Whether selection can be modified
  • allowUnselect (bool?, optional): Whether selection can be cleared by re-selection
  • child (Widget, required): Container with selectable choice items

Example:

ControlledMultipleChoice<Theme>(
  initialValue: Theme.dark,
  allowUnselect: false,
  onChanged: (theme) => setAppTheme(theme),
  child: ThemeSelector(),
);

Implementation

const ControlledMultipleChoice({
  super.key,
  this.controller,
  this.onChanged,
  this.initialValue,
  this.enabled = true,
  this.allowUnselect,
  required this.child,
});