SelectPickerNew<T> class

A modern, generic Select Picker widget that supports any data type T.

This widget provides a cleaner interface, custom builders, and built-in search. It is the recommended replacement for the legacy SelectPicker.

Example usage:

SelectPickerNew<String>(
  items: ['Apple', 'Banana', 'Orange'],
  onChanged: (value) => print(value),
  hint: 'Select a fruit',
)
Inheritance

Constructors

SelectPickerNew({Key? key, List<T>? items, String titleBuilder(T item)?, Widget itemBuilder(BuildContext context, T item, bool isSelected, VoidCallback onTap)?, T? initialValue, ValueChanged<T?>? onChanged, String hint = 'Select', String searchHint = 'Search...', bool showSearch = true, Future<List<T>> onSearch(String query)?, bool disabled = false, InputDecoration? decoration, Widget? emptyWidget, Widget? loadingWidget, bool compareFn(T a, T b)?, String? errorText, EdgeInsetsGeometry? contentPadding})
Creates a new SelectPickerNew instance.
const

Properties

compareFn bool Function(T a, T b)?
A custom function to determine if two items are equal.
final
contentPadding EdgeInsetsGeometry?
Custom padding inside the input field.
final
decoration InputDecoration?
The decoration to apply to the main input field.
final
disabled bool
Whether the picker is interactive.
final
emptyWidget Widget?
A widget to display when the list of items is empty or no search results are found.
final
errorText String?
An error message to display below the input field.
final
hashCode int
The hash code for this object.
no setterinherited
hint String
Placeholder text displayed when no item is selected.
final
initialValue → T?
The initially selected item value.
final
itemBuilder Widget Function(BuildContext context, T item, bool isSelected, VoidCallback onTap)?
A function to build a custom list item widget in the selection sheet.
final
items List<T>?
The list of items to select from.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
loadingWidget Widget?
A widget to display while an asynchronous search is in progress.
final
onChanged ValueChanged<T?>?
Called when the user selects an item from the picker.
final
onSearch Future<List<T>> Function(String query)?
An optional callback for asynchronous search.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
searchHint String
Placeholder text for the search input field.
final
showSearch bool
Whether to display a search field at the top of the selection sheet.
final
titleBuilder String Function(T item)?
A function to get the display title of an item.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<SelectPickerNew<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
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