ControlledMultiSelect<T> constructor
const
ControlledMultiSelect<T> ({
- Key? key,
- MultiSelectController<
T> ? controller, - ValueChanged<
Iterable< ? onChanged,T> ?> - bool enabled = true,
- Iterable<
T> ? initialValue, - Widget? placeholder,
- Widget? leading,
- Widget? trailing,
- Widget? indicatorIcon,
- 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> > - Widget? expandIcon = const SelectExpandIcon(),
- 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(MultiSelectController<T>?, optional): external state controllerinitialValue(Iterable<T>?, optional): starting selection when no controlleronChanged(ValueChanged<Iterable<T>?>?, optional): selection change callbackenabled(bool, default: true): whether select is interactiveplaceholder(Widget?, optional): widget shown when no items selectedleading(Widget?, optional): widget displayed before the selected valuestrailing(Widget?, optional): widget displayed after the selected valuesindicatorIcon(Widget?, optional): widget displayed as the dropdown indicatorfilled(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<T>, required): builder for individual items- multiItemBuilder (
SelectValueBuilder<T>, required): builder for selected items display valueSelectionHandler(SelectValueSelectionHandler<Iterable<T>>?, optional): custom selection logicvalueSelectionPredicate(SelectValueSelectionPredicate<Iterable<T>>?, optional): selection validationshowValuePredicate(Predicate<Iterable<T>>?, optional): visibility filter for valuesexpandIcon(Widget): The expand icon for the select, defaults to SelectExpandIcon widget
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.leading,
this.trailing,
this.indicatorIcon,
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,
this.expandIcon = const SelectExpandIcon(),
required this.popup,
required SelectValueBuilder<T> itemBuilder,
this.valueSelectionHandler,
this.valueSelectionPredicate,
}) : multiItemBuilder = itemBuilder;