Select<T> constructor

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

Creates a single-selection dropdown widget.

The popup and itemBuilder parameters are required to define the dropdown content and how selected values are displayed.

Parameters:

  • key (Key?): Widget key for controlling widget identity
  • onChanged (ValueChanged<T?>?): Callback when selection changes; if null, select is disabled
  • placeholder (Widget?): Widget shown when no value is selected
  • leading (Widget?): Widget displayed before the selected value or placeholder
  • trailing (Widget?): Widget displayed after the selected value or placeholder
  • indicatorIcon (Widget?): Widget displayed as the dropdown indicator
  • filled (bool): Whether to use filled background style, defaults to false
  • focusNode (FocusNode?): Focus node for keyboard interaction
  • constraints (BoxConstraints?): Size constraints for the select button
  • popupConstraints (BoxConstraints?): Size constraints for the popup menu
  • popupWidthConstraint (PopoverConstraint): Width constraint mode for popup, defaults to PopoverConstraint.anchorFixedSize
  • value (T?): Currently selected value
  • disableHoverEffect (bool): Whether to disable hover visual feedback, defaults to false
  • borderRadius (BorderRadiusGeometry?): Custom border radius
  • padding (EdgeInsetsGeometry?): Custom padding
  • popoverAlignment (AlignmentGeometry): Popup alignment, defaults to Alignment.topCenter
  • popoverAnchorAlignment (AlignmentGeometry?): Anchor alignment for popup positioning
  • canUnselect (bool): Whether user can deselect current value, defaults to false
  • autoClosePopover (bool?): Whether popup closes after selection, defaults to true
  • enabled (bool?): Whether select is enabled for interaction
  • valueSelectionHandler (SelectValueSelectionHandler<T>?): Custom selection logic
  • valueSelectionPredicate (SelectValueSelectionPredicate<T>?): Predicate for allowing selection
  • showValuePredicate (Predicate<T>?): Predicate for showing items
  • popup (SelectPopupBuilder): Required builder for popup content
  • itemBuilder (SelectValueBuilder<T>): Required builder for selected value display
  • expandIcon (Widget): The expand icon for the select, defaults to SelectExpandIcon widget

Implementation

const Select({
  super.key,
  this.onChanged,
  this.placeholder,
  this.leading,
  this.trailing,
  this.indicatorIcon,
  this.filled = false,
  this.focusNode,
  this.constraints,
  this.popupConstraints,
  this.popupWidthConstraint = PopoverConstraint.anchorFixedSize,
  this.value,
  this.disableHoverEffect = false,
  this.borderRadius,
  this.padding,
  this.popoverAlignment = Alignment.topCenter,
  this.popoverAnchorAlignment,
  this.canUnselect = false,
  this.autoClosePopover = true,
  this.enabled,
  this.valueSelectionHandler,
  this.valueSelectionPredicate,
  this.showValuePredicate,
  this.expandIcon = const SelectExpandIcon(),
  required this.popup,
  required this.itemBuilder,
});