ControlledSelect<T> constructor
const
ControlledSelect<T> ({
- Key? key,
- SelectController<
T> ? controller, - ValueChanged<
T?> ? onChanged, - bool enabled = true,
- 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 = false,
- bool autoClosePopover = true,
- required SelectPopupBuilder popup,
- required SelectValueBuilder<
T> itemBuilder, - SelectValueSelectionHandler<
T> ? valueSelectionHandler, - SelectValueSelectionPredicate<
T> ? valueSelectionPredicate, - Predicate<
T> ? showValuePredicate,
Creates a ControlledSelect.
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
(SelectControllerinitialValue
(T?, optional): starting selection when no controlleronChanged
(ValueChanged<T?>?, optional): selection change callbackenabled
(bool, default: true): whether select is interactiveplaceholder
(Widget?, optional): widget shown when no item 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 current itemautoClosePopover
(bool, default: true): close popup after selectionpopup
(SelectPopupBuilder, required): builder for popup contentitemBuilder
(SelectItemBuildervalueSelectionHandler
(SelectValueSelectionHandlervalueSelectionPredicate
(SelectValueSelectionPredicateshowValuePredicate
(Predicate
Example:
ControlledSelect<String>(
controller: controller,
popup: (context, items) => ListView(children: items),
itemBuilder: (context, item, selected) => Text(item),
placeholder: Text('Select option'),
)
Implementation
const ControlledSelect({
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 = false,
this.autoClosePopover = true,
required this.popup,
required this.itemBuilder,
this.valueSelectionHandler,
this.valueSelectionPredicate,
this.showValuePredicate,
});