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.

Constructors

SearchChoices.multiple({dynamic key, List? items, Function? onChanged, List<int> selectedItems = const [], dynamic 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, dynamic clearIcon = const Icon(Icons.clear), dynamic iconEnabledColor, dynamic iconDisabledColor, double iconSize = 24.0, bool isExpanded = false, bool isCaseSensitiveSearch = false, Function? searchFn, Function? onClear, Function? selectedValueWidgetFn, dynamic keyboardType = TextInputType.text, String? validator(T?)?, Function? displayItem, bool dialogBox = true, dynamic menuConstraints, bool readOnly = false, dynamic menuBackgroundColor, bool rightToLeft = false, bool autofocus = true, Function? selectedAggregateWidgetFn, dynamic padding, Function? setOpenDialog, dynamic buildDropDownDialog(dynamic titleBar, dynamic searchBar, dynamic list, dynamic closeButton, dynamic dropDownContext)?, dynamic dropDownDialogPadding, dynamic searchInputDecoration, int? itemsPerPage, PointerThisPlease<int>? currentPage, dynamic customPaginationDisplay(dynamic listWidget, int totalFilteredItemsNb, Function updateSearchPage)?, Future<Tuple2<List, int>> futureSearchFn(String? keyword, String? orderBy, bool? orderAsc, List<Tuple2<String, String>>? filters, int? pageNb)?, Map<String, Map<String, dynamic>>? futureSearchOrderOptions, Map<String, Map<String, Object>>? futureSearchFilterOptions, List<T>? futureSelectedValues, dynamic emptyListWidget, Function? onTap, Function? futureSearchRetryButton, int? searchDelay, dynamic fieldPresentationFn(dynamic fieldWidget, {bool selectionIsValid})?, dynamic fieldDecoration, dynamic clearSearchIcon, Future<void> showDialogFn(dynamic context, dynamic menuWidget({String searchTerms}), String searchTerms)?, dynamic onSaved, String? listValidator(List)?, dynamic autovalidateMode = AutovalidateMode.onUserInteraction, String? restorationId})
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({dynamic key, List? items, Function? onChanged, T? value, dynamic 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, dynamic clearIcon = const Icon(Icons.clear), dynamic iconEnabledColor, dynamic iconDisabledColor, double iconSize = 24.0, bool isExpanded = false, bool isCaseSensitiveSearch = false, Function? searchFn, Function? onClear, Function? selectedValueWidgetFn, dynamic keyboardType = TextInputType.text, String? validator(T?)?, bool assertUniqueValue = true, Function? displayItem, bool dialogBox = true, dynamic menuConstraints, bool readOnly = false, dynamic menuBackgroundColor, bool rightToLeft = false, bool autofocus = true, Function? selectedAggregateWidgetFn, dynamic padding, Function? setOpenDialog, dynamic buildDropDownDialog(dynamic titleBar, dynamic searchBar, dynamic list, dynamic closeButton, dynamic dropDownContext)?, dynamic dropDownDialogPadding, dynamic searchInputDecoration, int? itemsPerPage, PointerThisPlease<int>? currentPage, dynamic customPaginationDisplay(dynamic listWidget, int totalFilteredItemsNb, Function updateSearchPage)?, Future<Tuple2<List, int>> futureSearchFn(String? keyword, String? orderBy, bool? orderAsc, List<Tuple2<String, String>>? filters, int? pageNb)?, Map<String, Map<String, dynamic>>? futureSearchOrderOptions, Map<String, Map<String, Object>>? futureSearchFilterOptions, dynamic emptyListWidget, Function? onTap, Function? futureSearchRetryButton, int? searchDelay, dynamic fieldPresentationFn(dynamic fieldWidget, {bool selectionIsValid})?, dynamic fieldDecoration, dynamic clearSearchIcon, Future<void> showDialogFn(dynamic context, dynamic menuWidget({String searchTerms}), String searchTerms)?, dynamic onSaved, dynamic autovalidateMode = AutovalidateMode.onUserInteraction, String? restorationId})
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
autovalidateMode → dynamic
autovalidateMode as in FormField.
final
buildDropDownDialog → (dynamic Function?(dynamic titleBar, dynamic searchBar, dynamic list, dynamic closeButton, dynamic dropDownContext)?)
buildDropDownDialog Function controls the layout of the dropdown dialog. If null, equivalent to:
final
clearIcon → dynamic
clearIcon Icon to be used for clearing the selected value.
final
clearSearchIcon → dynamic
clearSearchIcon Widget sets the icon to be used to clear the search.
final
closeButton → dynamic
closeButton String|Widget|Function with parameter: value returning String|Widget displayed at the bottom of the search dialog box.
final
currentPage PointerThisPlease<int>?
currentPage PointerThisPlease<int> if itemsPerPage is set, holds the page number for the search items to be displayed.
final
customPaginationDisplay → (dynamic Function?(dynamic listWidget, int totalFilteredItemsNb, Function updateSearchPage)?)
customPaginationDisplay Widget Function(Widget listWidget, int totalFilteredItemsNb, Function updateSearchPage) if itemsPerPage is set, customizes the display and the handling of the pagination on the search list.
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
dropDownDialogPadding EdgeInsets sets the padding between the screen and the dialog.
final
emptyListWidget → dynamic
emptyListWidget String|Widget|Function with parameter: keyword returning String|Widget displayed instead of the list of items in case it is empty.
final
fieldDecoration → dynamic
fieldDecoration Decoration is the decoration of the SearchChoices Widget while displaying the hints or the selected values. Should differ when selection is not valid.
final
fieldPresentationFn → (dynamic Function?(dynamic fieldWidget, {bool selectionIsValid})?)
fieldPresentationFn Function returning a Widget to customize the display of the field.
final
futureSearchFilterOptions Map<String, Map<String, Object>>?
futureSearchFilterOptions Map<String, Map<String, Object>> when futureSearchFn is set, can be used to display search filters specified in the form {"filter1Name": {"icon":filter1IconWidget, "values":["value1",{"value2":filter1Value2Widget}}}. Please refer to the documentation example: https://github.com/lcuis/search_choices/blob/master/example/lib/main.dart.
final
futureSearchFn → (Future<Tuple2<List, int>> Function?(String? keyword, String? orderBy, bool? orderAsc, List<Tuple2<String, String>>? filters, int? pageNb)?)
futureSearchFn Future Function(String keyword, List itemsListToClearAndFill, int pageNb) used to search items from the network. Must return items (up to itemsPerPage if set). Must return an int with the total number of results (allows the handling of pagination).
final
futureSearchOrderOptions Map<String, Map<String, dynamic>>?
futureSearchOrderOptions Map<String, Map<String,dynamic>> when futureSearchFn is set, can be used to display search order options specified in the form {"order1Name":{"icon":order1IconWidget,"asc":true},}. Please refer to the documentation example: https://github.com/lcuis/search_choices/blob/master/example/lib/main.dart.
final
futureSearchRetryButton Function?
futureSearchRetryButton Function called to customize the Error - retry button displayed when there is an issue with the future search.
final
futureSelectedValues List<T>?
futureSelectedValues List<T> contains the list of selected values in case of future search in multiple selection mode.
final
hashCode int
The hash code for this object.
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 → dynamic
iconDisabledColor Color to be used for disabled icons.
final
iconEnabledColor → dynamic
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
isEnabled bool
read-only
isExpanded bool
isExpanded can be necessary to avoid pixel overflows (zebra symptom).
final
items List?
items with child: Widget displayed ; value: any object with .toString() used to match search keyword.
final
itemsPerPage int?
itemsPerPage int if set, organizes the search list per page with the given number of items displayed per page. Must give currentPage.
final
keyboardType → dynamic
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
listValidator → (String? Function?(List<T?>)?)
listValidator Function with parameter: List returning String displayed below selected value when not valid and null when valid.
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
onSaved → dynamic
onSaved as in FormField.
final
onTap Function?
onTap Function called when the user clicks on the Widget before it opens the dialog or the menu. Note that this is not called in case the Widget is disabled.
final
padding → dynamic
padding double or EdgeInsets 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
restorationId String?
restorationId as in FormField.
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
searchDelay int?
searchDelay int in milliseconds applied before the search is initiated. This applies to future and non-future searches.
final
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
searchInputDecoration → dynamic
searchInputDecoration InputDecoration sets the search bar decoration.
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
showDialogFn → (Future<void> Function?(dynamic context, dynamic menuWidget({String searchTerms}), String searchTerms)?)
showDialogFn Function allows the control of the dialog display.
final
style → dynamic
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 → (String? Function?(T?)?)
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

createState() → _SearchChoicesState<T>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

dialogBoxMenuWrapper ↔ (dynamic Function?(dynamic)?)
dialogBoxMenuWrapper Function called to wrap the menu widget when in dialog box mode. This is useful for testing mainly.
read / write