SearchChoices<T> class Null safety

SearchChoices widget that allows the opening of a searchable dropdown. Use the SearchChoices.single factory if only one item needs to be selected. Use the SearchChoices.multiple factory if user must be able to select multiple items at once.

Inheritance

Constructors

SearchChoices.multiple({Key? key, required List<DropdownMenuItem<T>> items, Function? onChanged, List<int> selectedItems = const [], TextStyle? style, dynamic searchHint, dynamic hint, dynamic disabledHint, dynamic icon = const Icon(Icons.arrow_drop_down), dynamic underline, dynamic doneButton = "Done", dynamic label, dynamic closeButton = "Close", bool displayClearIcon = true, Icon clearIcon = const Icon(Icons.clear), Color? iconEnabledColor, Color? iconDisabledColor, double iconSize = 24.0, bool isExpanded = false, bool isCaseSensitiveSearch = false, Function? searchFn, Function? onClear, Function? selectedValueWidgetFn, TextInputType keyboardType = TextInputType.text, Function? validator, Function? displayItem, bool dialogBox = true, BoxConstraints? menuConstraints, bool readOnly = false, Color? menuBackgroundColor, bool rightToLeft = false, bool autofocus = true, Function? selectedAggregateWidgetFn, double padding = 10.0, Function? setOpenDialog})
Search choices Widget with a multiple choice that opens a dialog or a menu to let the user do the selection conveniently with a search. [...]
factory
SearchChoices.single({Key? key, required List<DropdownMenuItem<T>> items, Function? onChanged, T? value, TextStyle? style, dynamic searchHint, dynamic hint, dynamic disabledHint, dynamic icon = const Icon(Icons.arrow_drop_down), dynamic underline, dynamic doneButton, dynamic label, dynamic closeButton = "Close", bool displayClearIcon = true, Icon clearIcon = const Icon(Icons.clear), Color? iconEnabledColor, Color? iconDisabledColor, double iconSize = 24.0, bool isExpanded = false, bool isCaseSensitiveSearch = false, Function? searchFn, Function? onClear, Function? selectedValueWidgetFn, TextInputType keyboardType = TextInputType.text, Function? validator, bool assertUniqueValue = true, Function? displayItem, bool dialogBox = true, BoxConstraints? menuConstraints, bool readOnly = false, Color? menuBackgroundColor, bool rightToLeft = false, bool autofocus = true, Function? selectedAggregateWidgetFn, double padding = 10.0, Function? setOpenDialog})
Search choices Widget with a single choice that opens a dialog or a menu to let the user do the selection conveniently with a search. [...]
factory

Properties

autofocus bool
autofocus bool automatically focuses on the search field bringing up the keyboard defaulted to true.
final
clearIcon Icon
clearIcon Icon to be used for clearing the selected value.
final
closeButton → dynamic
closeButton String|Widget|Function with parameter: value returning String|Widget displayed at the bottom of the search dialog box.
final
dialogBox bool
dialogBox whether the search should be displayed as a dialog box or as a menu below the selected value if any.
final
disabledHint → dynamic
disabledHint String|Widget|Function with no parameter returning String|Widget displayed instead of hint when the widget is displayed.
final
displayClearIcon bool
displayClearIcon whether or not to display an icon to clear the selected value.
final
displayItem Function?
displayItem Function with parameters: item, selected returning Widget to be displayed in the search list.
final
doneButton → dynamic
doneButton String|Widget|Function with parameter: value returning String|Widget displayed at the top of the search dialog box.
final
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
hint → dynamic
hint String|Widget|Function with no parameter returning String|Widget displayed before any value is selected or after the selection is cleared.
final
icon → dynamic
icon String|Widget|Function with parameter: value returning String|Widget displayed next to the selected item or the hint if none.
final
iconDisabledColor Color?
iconDisabledColor Color to be used for disabled icons.
final
iconEnabledColor Color?
iconEnabledColor Color to be used for enabled icons.
final
iconSize double
iconSize for the icons next to the selected value (icon and clearIcon).
final
isCaseSensitiveSearch bool
isCaseSensitiveSearch only used when searchFn is not specified.
final
isExpanded bool
isExpanded can be necessary to avoid pixel overflows (zebra symptom).
final
items List<DropdownMenuItem<T>>
items with child: Widget displayed ; value: any object with .toString() used to match search keyword.
final
key Key?
Controls how one widget replaces another widget in the tree. [...]
final, inherited
keyboardType TextInputType
keyboardType used for the search.
final
label → dynamic
label String|Widget|Function with parameter: value returning String|Widget displayed above the selected item or the hint if none.
final
menuBackgroundColor Color background color of the menu whether in dialog box or menu mode.
final
menuConstraints BoxConstraints used to define the zone where to display the search menu. Example: BoxConstraints.tight(Size.fromHeight(250)) . Not to be used for dialogBox = true.
final
multipleSelection bool
multipleSelection indicates whether user can select one or more items.
final
onChanged Function?
onChanged Function with parameter: value not returning executed after the selection is done.
final
onClear Function?
onClear Function with no parameter not returning executed when the clear icon is tapped.
final
padding double
padding double sets the padding around the DropdownButton, defaulted to 10.0.
final
readOnly bool
readOnly bool whether to let the user choose the value to select or just present the selected value if any.
final
rightToLeft bool
rightToLeft bool mirrors the widgets display for right to left languages defaulted to false.
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
searchFn Function?
searchFn Function with parameters: keyword, items returning List<int> as the list of indexes for the items to be displayed.
final
searchHint → dynamic
searchHint String|Widget|Function with no parameter returning String|Widget displayed at the top of the search dialog box.
final
selectedAggregateWidgetFn Function?
selectedAggregateWidgetFn Function with parameter: list of widgets presenting selected values , returning Widget to be displayed to present the selected items.
final
selectedItems List<int>
selectedItems indexes of items to be preselected.
final
selectedValueWidgetFn Function?
selectedValueWidgetFn Function with parameter: item returning Widget to be used to display the selected value.
final
setOpenDialog Function?
setOpenDialog Function sets the function to call to set the function to call in order to open the dialog with the search terms string as a parameter, defaulted to null.
final
style TextStyle?
style used for the hint if it is given is String.
final
underline → dynamic
underline String|Widget|Function with parameter: value returning String|Widget displayed below the selected item or the hint if none.
final
validator Function?
validator Function with parameter: value returning String displayed below selected value when not valid and null when valid.
final
value → T?
value value to be preselected.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
inherited
createState() → _SearchChoicesState<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. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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}) 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. [...]
@nonVirtual, inherited