ShadSelect<T> class
A customizable select dropdown widget with various variants and options.
It supports single and multiple selection, search functionality, and extensive customization through various properties.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ShadSelect
- Available extensions
Constructors
-
ShadSelect({Key? key, required ShadSelectedOptionBuilder<
T> ? selectedOptionBuilder, Iterable<Widget> ? options, Widget? optionsBuilder(BuildContext, int)?, ShadPopoverController? popoverController, bool enabled = true, Widget? placeholder, TextStyle? placeholderStyle, T? initialValue, ValueChanged<T?> ? onChanged, FocusNode? focusNode, bool closeOnTapOutside = true, double? minWidth, double? maxWidth, double? maxHeight, ShadDecoration? decoration, Widget? trailing, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? optionsPadding, bool? showScrollToBottomChevron, bool? showScrollToTopChevron, ScrollController? scrollController, ShadAnchorBase? anchor, List<Effect> ? effects, List<BoxShadow> ? shadows, ImageFilter? filter, Widget? header, bool closeOnSelect = true, bool allowDeselection = false, Object? groupId, int? itemCount, bool? shrinkWrap, ShadSelectController<T> ? controller, Duration? popoverReverseDuration, bool? ensureSelectedVisible, VoidCallback? onPressed}) -
Creates a ShadSelect with the primary variant.
const
-
ShadSelect.multiple({Key? key, Iterable<
Widget> ? options, Widget? optionsBuilder(BuildContext, int)?, required ShadSelectedOptionBuilder<List< ? selectedOptionsBuilder, ShadPopoverController? popoverController, bool enabled = true, Widget? placeholder, TextStyle? placeholderStyle, Set<T> >T> initialValues = const {}, ValueChanged<Set< ? onChanged, FocusNode? focusNode, bool closeOnTapOutside = true, double? minWidth, double? maxWidth, double? maxHeight, ShadDecoration? decoration, Widget? trailing, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? optionsPadding, bool? showScrollToBottomChevron, bool? showScrollToTopChevron, ScrollController? scrollController, ShadAnchorBase? anchor, List<T> >Effect> ? effects, List<BoxShadow> ? shadows, ImageFilter? filter, Widget? header, bool allowDeselection = true, bool closeOnSelect = true, Object? groupId, int? itemCount, bool? shrinkWrap, ShadSelectController<T> ? controller, Duration? popoverReverseDuration, bool? ensureSelectedVisible, VoidCallback? onPressed}) -
Creates a ShadSelect with the multiple select variant.
const
-
ShadSelect.multipleWithSearch({Key? key, Iterable<
Widget> ? options, Widget? optionsBuilder(BuildContext, int)?, ValueChanged<String> ? onSearchChanged, required ShadSelectedOptionBuilder<List< ? selectedOptionsBuilder, ValueChanged<T> >Set< ? onChanged, ShadPopoverController? popoverController, Widget? searchDivider, Widget? searchInputLeading, Widget? searchPlaceholder, EdgeInsetsGeometry? searchPadding, Widget? search, bool? clearSearchOnClose, bool enabled = true, Widget? placeholder, TextStyle? placeholderStyle, Set<T> >T> initialValues = const {}, FocusNode? focusNode, bool closeOnTapOutside = true, double? minWidth, double? maxWidth, double? maxHeight, ShadDecoration? decoration, Widget? trailing, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? optionsPadding, bool? showScrollToBottomChevron, bool? showScrollToTopChevron, ScrollController? scrollController, ShadAnchorBase? anchor, List<Effect> ? effects, List<BoxShadow> ? shadows, ImageFilter? filter, Widget? header, bool allowDeselection = true, bool closeOnSelect = true, Object? groupId, int? itemCount, bool? shrinkWrap, ShadSelectController<T> ? controller, Duration? popoverReverseDuration, bool? ensureSelectedVisible, FocusNode? searchFocusNode, ValueChanged<String> ? onSearchSubmitted, VoidCallback? onPressed}) -
Creates a ShadSelect with the multiple select and search variant.
const
-
ShadSelect.raw({Key? key, required ShadSelectVariant variant, Iterable<
Widget> ? options, Widget? optionsBuilder(BuildContext, int)?, ShadSelectedOptionBuilder<T> ? selectedOptionBuilder, ShadSelectedOptionBuilder<List< ? selectedOptionsBuilder, ShadPopoverController? popoverController, ValueChanged<T> >String> ? onSearchChanged, Widget? searchDivider, Widget? searchInputLeading, Widget? searchPlaceholder, EdgeInsetsGeometry? searchPadding, Widget? search, bool? clearSearchOnClose, bool enabled = true, Widget? placeholder, TextStyle? placeholderStyle, T? initialValue, Set<T> initialValues = const {}, ValueChanged<T?> ? onChanged, ValueChanged<Set< ? onMultipleChanged, FocusNode? focusNode, bool closeOnTapOutside = true, double? minWidth, double? maxWidth, double? maxHeight, ShadDecoration? decoration, Widget? trailing, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? optionsPadding, bool? showScrollToBottomChevron, bool? showScrollToTopChevron, ScrollController? scrollController, ShadAnchorBase? anchor, List<T> >Effect> ? effects, List<BoxShadow> ? shadows, ImageFilter? filter, Widget? header, bool allowDeselection = false, bool closeOnSelect = true, Object? groupId, int? itemCount, bool? shrinkWrap, ShadSelectController<T> ? controller, Duration? popoverReverseDuration, bool? ensureSelectedVisible, FocusNode? searchFocusNode, ValueChanged<String> ? onSearchSubmitted, VoidCallback? onPressed}) -
Creates a ShadSelect with a raw variant, allowing full customization.
const
-
ShadSelect.withSearch({Key? key, Iterable<
Widget> ? options, Widget? optionsBuilder(BuildContext, int)?, required ShadSelectedOptionBuilder<T> ? selectedOptionBuilder, ValueChanged<String> ? onSearchChanged, ValueChanged<T?> ? onChanged, ShadPopoverController? popoverController, Widget? searchDivider, Widget? searchInputLeading, Widget? searchPlaceholder, EdgeInsetsGeometry? searchPadding, Widget? search, bool? clearSearchOnClose, bool enabled = true, Widget? placeholder, TextStyle? placeholderStyle, T? initialValue, FocusNode? focusNode, bool closeOnTapOutside = true, double? minWidth, double? maxWidth, double? maxHeight, ShadDecoration? decoration, Widget? trailing, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? optionsPadding, bool? showScrollToBottomChevron, bool? showScrollToTopChevron, ScrollController? scrollController, ShadAnchorBase? anchor, List<Effect> ? effects, List<BoxShadow> ? shadows, ImageFilter? filter, Widget? header, bool closeOnSelect = true, bool allowDeselection = false, Object? groupId, int? itemCount, bool? shrinkWrap, ShadSelectController<T> ? controller, Duration? popoverReverseDuration, bool? ensureSelectedVisible, FocusNode? searchFocusNode, ValueChanged<String> ? onSearchSubmitted, VoidCallback? onPressed}) -
Creates a ShadSelect with the search variant.
const
Properties
- allowDeselection → bool
-
Whether the ShadSelect allows deselection, defaults to
false.final - anchor → ShadAnchorBase?
-
The anchor configuration for positioning the popover relative to the
select input.
final
- clearSearchOnClose → bool?
-
Whether to clear the search input when the popover is closed.
final
- closeOnSelect → bool
-
Whether to automatically close the popover when an option is selected.
final
- closeOnTapOutside → bool
-
Whether to close the select popover when tapping outside of it.
final
-
controller
→ ShadSelectController<
T> ? -
The controller of the ShadSelect.
final
- decoration → ShadDecoration?
-
The visual decoration of the select input.
final
-
effects
→ List<
Effect> ? -
The animation effects applied to the
popover. Defaults toFadeEffect(), ScaleEffect(begin: Offset(.95, .95), end: Offset(1, 1)), MoveEffect(begin: Offset(0, 2), end: Offset(0, 0)).final - enabled → bool
-
Whether the ShadSelect is enabled.
final
- ensureSelectedVisible → bool?
-
Whether to automatically scroll the options list to ensure the selected
option is visible when the popover opens.
Defaults to true if the variant is ShadSelectVariant.primary or
ShadSelectVariant.search, false otherwise.
final
- filter → ImageFilter?
-
The filter of the
popover. Ifnull, falls back toShadPopoverTheme.final - focusNode → FocusNode?
-
The focus node to control the focus state of the ShadSelect.
final
-
Widget to display at the bottom of the popover, below the options list.
final
- groupId → Object?
-
Group ID for the popover, used for managing popover visibility in groups.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- header → Widget?
-
Widget to display at the top of the popover, above the options list.
final
- initialValue → T?
-
The initially selected value for single select ShadSelect variants.
final
-
initialValues
→ Set<
T> -
The initial values of the ShadSelect, defaults to
[].final - itemCount → int?
-
The number of items to display when using optionsBuilder.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- maxHeight → double?
-
The maximum height of the select popover.
final
- maxWidth → double?
-
The maximum width of the select input and popover.
final
- minWidth → double?
-
The minimum width of the select input and popover.
final
-
onChanged
→ ValueChanged<
T?> ? -
The callback that is called when the value of the ShadSelect changes.
final
-
onMultipleChanged
→ ValueChanged<
Set< ?T> > -
The callback that is called when the values of the ShadSelect changes.
Called only the variant is ShadSelect.multiple.
final
- onPressed → VoidCallback?
-
Callback function invoked when the select input is pressed.
final
-
onSearchChanged
→ ValueChanged<
String> ? -
Callback function invoked when the search query changes in search-enabled
ShadSelect variants.
final
-
onSearchSubmitted
→ ValueChanged<
String> ? -
Callback function invoked when the search query is submitted in
search-enabled
ShadSelect variants.
Provides the current search string as an argument.
final
-
options
→ Iterable<
Widget> ? -
An iterable of widgets representing the selectable options.
final
- optionsBuilder → Widget? Function(BuildContext, int)?
-
A builder function for creating options widgets on demand.
final
- optionsPadding → EdgeInsetsGeometry?
-
The padding around the options within the popover.
final
- padding → EdgeInsetsGeometry?
-
The padding around the content of the select input.
final
- placeholder → Widget?
-
The widget to display as a placeholder when no option is selected.
final
- placeholderStyle → TextStyle?
-
The text style to apply by default to the placeholder widget.
If the placeholder contains a Text widget, this style will be merged
with its existing style.
final
- popoverController → ShadPopoverController?
-
Controller for managing the visibility and behavior of the popover.
final
- popoverReverseDuration → Duration?
-
The duration of the popover's exit animation.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollController → ScrollController?
-
The scroll controller for the options list in the popover.
final
- search → Widget?
-
A completely customizable search input widget.
final
- searchDivider → Widget?
-
Widget to display as a divider between the search input and the options
list
in search-enabled ShadSelect variants.
final
- searchFocusNode → FocusNode?
-
Focus node for the search input field in search-enabled variants.
If null, a default FocusNode will be created internally.
final
- searchInputLeading → Widget?
-
Widget to display at the leading edge of the search input field.
final
- searchPadding → EdgeInsetsGeometry?
-
Padding around the search input field.
final
- searchPlaceholder → Widget?
-
Placeholder text to display in the search input field when no query is
entered.
final
-
selectedOptionBuilder
→ ShadSelectedOptionBuilder<
T> ? -
Builder function for rendering the currently selected option in single
select ShadSelect variants.
final
-
selectedOptionsBuilder
→ ShadSelectedOptionBuilder<
List< ?T> > -
Builder function for rendering the currently selected options in multiple
select ShadSelect variants.
final
-
shadows
→ List<
BoxShadow> ? -
The shadows applied to the
popover, defaults to ShadShadows.md.final - showScrollToBottomChevron → bool?
-
Whether to display a chevron icon at the bottom of the popover when
scrollable. Defaults to
true.final - showScrollToTopChevron → bool?
-
Whether to display a chevron icon at the top of the popover when
scrollable. Defaults to
true.final - shrinkWrap → bool?
-
Whether the options list should shrink-wrap its content.
final
- trailing → Widget?
-
The widget to display at the end of the select input, typically an icon.
final
- variant → ShadSelectVariant
-
The variant of the ShadSelect widget, determining its behavior and
appearance.
final
Methods
-
animate(
{Key? key, List< Effect> ? effects, AnimateCallback? onInit, AnimateCallback? onPlay, AnimateCallback? onComplete, bool? autoPlay, Duration? delay, AnimationController? controller, Adapter? adapter, double? target, double? value}) → Animate -
Available on Widget, provided by the AnimateWidgetExtensions extension
Wraps the target Widget in an Animate instance, and returns the instance for chaining calls. Ex.myWidget.animate()is equivalent toAnimate(child: myWidget). -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → ShadSelectState< T> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
positionedWith(
ShadPosition position) → Widget -
Available on Widget, provided by the PositionedExt extension
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited