ControlledMultiSelect<T> constructor

const ControlledMultiSelect<T>({
  1. Key? key,
  2. MultiSelectController<T>? controller,
  3. ValueChanged<Iterable<T>?>? onChanged,
  4. bool enabled = true,
  5. Iterable<T>? initialValue,
  6. Widget? placeholder,
  7. bool filled = false,
  8. FocusNode? focusNode,
  9. BoxConstraints? constraints,
  10. BoxConstraints? popupConstraints,
  11. PopoverConstraint popupWidthConstraint = PopoverConstraint.anchorFixedSize,
  12. BorderRadiusGeometry? borderRadius,
  13. EdgeInsetsGeometry? padding,
  14. AlignmentGeometry popoverAlignment = Alignment.topCenter,
  15. AlignmentGeometry? popoverAnchorAlignment,
  16. bool disableHoverEffect = false,
  17. bool canUnselect = true,
  18. bool autoClosePopover = false,
  19. Predicate<Iterable<T>>? showValuePredicate,
  20. required SelectPopupBuilder popup,
  21. required SelectValueBuilder<T> itemBuilder,
  22. SelectValueSelectionHandler<Iterable<T>>? valueSelectionHandler,
  23. SelectValueSelectionPredicate<Iterable<T>>? valueSelectionPredicate,
})

Creates a ControlledMultiSelect.

Either controller or onChanged should be provided for interactivity. The widget supports both controller-based and callback-based state management patterns with multiple item selection capabilities.

Parameters:

  • controller (MultiSelectController
  • initialValue (Iterable
  • onChanged (ValueChanged<Iterable
  • enabled (bool, default: true): whether select is interactive
  • placeholder (Widget?, optional): widget shown when no items selected
  • filled (bool, default: false): whether to use filled appearance
  • focusNode (FocusNode?, optional): custom focus node for keyboard handling
  • constraints (BoxConstraints?, optional): size constraints for select widget
  • popupConstraints (BoxConstraints?, optional): size constraints for popup
  • popupWidthConstraint (PopoverConstraint, default: anchorFixedSize): popup width behavior
  • borderRadius (BorderRadiusGeometry?, optional): override select border radius
  • padding (EdgeInsetsGeometry?, optional): override internal padding
  • popoverAlignment (AlignmentGeometry, default: topCenter): popup alignment
  • popoverAnchorAlignment (AlignmentGeometry?, optional): anchor alignment
  • disableHoverEffect (bool, default: false): disable item hover effects
  • canUnselect (bool, default: false): allow deselecting all items
  • autoClosePopover (bool, default: false): close popup after each selection
  • popup (SelectPopupBuilder, required): builder for popup content
  • itemBuilder (SelectItemBuilder
  • multiItemBuilder (SelectValueBuilder
  • valueSelectionHandler (SelectValueSelectionHandler<Iterable
  • valueSelectionPredicate (SelectValueSelectionPredicate<Iterable
  • showValuePredicate (Predicate<Iterable

Example:

ControlledMultiSelect<String>(
  controller: controller,
  popup: (context, items) => ListView(children: items),
  itemBuilder: (context, item, selected) => CheckboxListTile(
    value: selected,
    title: Text(item),
  ),
  multiItemBuilder: (context, items) => Wrap(
    children: items.map((item) => Chip(label: Text(item))).toList(),
  ),
)

Implementation

const ControlledMultiSelect({
  super.key,
  this.controller,
  this.onChanged,
  this.enabled = true,
  this.initialValue,
  this.placeholder,
  this.filled = false,
  this.focusNode,
  this.constraints,
  this.popupConstraints,
  this.popupWidthConstraint = PopoverConstraint.anchorFixedSize,
  this.borderRadius,
  this.padding,
  this.popoverAlignment = Alignment.topCenter,
  this.popoverAnchorAlignment,
  this.disableHoverEffect = false,
  this.canUnselect = true,
  this.autoClosePopover = false,
  this.showValuePredicate,
  required this.popup,
  required SelectValueBuilder<T> itemBuilder,
  this.valueSelectionHandler,
  this.valueSelectionPredicate,
}) : multiItemBuilder = itemBuilder;