ControlledMultiSelect<T> constructor
const
ControlledMultiSelect<T> ({
- Key? key,
- MultiSelectController<
T> ? controller, - ValueChanged<
Iterable< ? onChanged,T> ?> - bool enabled = true,
- Iterable<
T> ? initialValue, - Widget? placeholder,
- bool filled = false,
- FocusNode? focusNode,
- BoxConstraints? constraints,
- BoxConstraints? popupConstraints,
- PopoverConstraint popupWidthConstraint = PopoverConstraint.anchorFixedSize,
- BorderRadiusGeometry? borderRadius,
- EdgeInsetsGeometry? padding,
- AlignmentGeometry popoverAlignment = Alignment.topCenter,
- AlignmentGeometry? popoverAnchorAlignment,
- bool disableHoverEffect = false,
- bool canUnselect = true,
- bool autoClosePopover = false,
- Predicate<
Iterable< ? showValuePredicate,T> > - required SelectPopupBuilder popup,
- required SelectValueBuilder<
T> itemBuilder, - SelectValueSelectionHandler<
Iterable< ? valueSelectionHandler,T> > - SelectValueSelectionPredicate<
Iterable< ? valueSelectionPredicate,T> >
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
(MultiSelectControllerinitialValue
(IterableonChanged
(ValueChanged<Iterableenabled
(bool, default: true): whether select is interactiveplaceholder
(Widget?, optional): widget shown when no items selectedfilled
(bool, default: false): whether to use filled appearancefocusNode
(FocusNode?, optional): custom focus node for keyboard handlingconstraints
(BoxConstraints?, optional): size constraints for select widgetpopupConstraints
(BoxConstraints?, optional): size constraints for popuppopupWidthConstraint
(PopoverConstraint, default: anchorFixedSize): popup width behaviorborderRadius
(BorderRadiusGeometry?, optional): override select border radiuspadding
(EdgeInsetsGeometry?, optional): override internal paddingpopoverAlignment
(AlignmentGeometry, default: topCenter): popup alignmentpopoverAnchorAlignment
(AlignmentGeometry?, optional): anchor alignmentdisableHoverEffect
(bool, default: false): disable item hover effectscanUnselect
(bool, default: false): allow deselecting all itemsautoClosePopover
(bool, default: false): close popup after each selectionpopup
(SelectPopupBuilder, required): builder for popup contentitemBuilder
(SelectItemBuilder- multiItemBuilder (SelectValueBuilder
valueSelectionHandler
(SelectValueSelectionHandler<IterablevalueSelectionPredicate
(SelectValueSelectionPredicate<IterableshowValuePredicate
(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;