ControlledSelect<T> constructor

const ControlledSelect<T>({
  1. Key? key,
  2. SelectController<T>? controller,
  3. ValueChanged<T?>? onChanged,
  4. bool enabled = true,
  5. 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 = false,
  18. bool autoClosePopover = true,
  19. required SelectPopupBuilder popup,
  20. required SelectValueBuilder<T> itemBuilder,
  21. SelectValueSelectionHandler<T>? valueSelectionHandler,
  22. SelectValueSelectionPredicate<T>? valueSelectionPredicate,
  23. 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 (SelectController
  • initialValue (T?, optional): starting selection when no controller
  • onChanged (ValueChanged<T?>?, optional): selection change callback
  • enabled (bool, default: true): whether select is interactive
  • placeholder (Widget?, optional): widget shown when no item 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 current item
  • autoClosePopover (bool, default: true): close popup after selection
  • popup (SelectPopupBuilder, required): builder for popup content
  • itemBuilder (SelectItemBuilder
  • valueSelectionHandler (SelectValueSelectionHandler
  • valueSelectionPredicate (SelectValueSelectionPredicate
  • showValuePredicate (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,
});