CustomDropdownTCB<T> class

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

Inheritance

Constructors

CustomDropdownTCB.multiple({Key? key, List<TCBDropdownMenuItem<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, Widget buildDropDownDialog(Widget titleBar, Widget searchBar, Widget list, Widget closeButton, BuildContext dropDownContext)?, InputDecoration? searchInputDecoration, int? itemsPerPage, PointerThisPlease<int>? currentPage, Widget customPaginationDisplay(Widget listWidget, int totalFilteredItemsNb, Function updateSearchPage)?, Future<Tuple2<List<TCBDropdownMenuItem>, 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})
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
CustomDropdownTCB.single({Key? key, List<TCBDropdownMenuItem<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, Widget buildDropDownDialog(Widget titleBar, Widget searchBar, Widget list, Widget closeButton, BuildContext dropDownContext)?, InputDecoration? searchInputDecoration, int? itemsPerPage, PointerThisPlease<int>? currentPage, Widget customPaginationDisplay(Widget listWidget, int totalFilteredItemsNb, Function updateSearchPage)?, Future<Tuple2<List<TCBDropdownMenuItem>, 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})
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
buildDropDownDialog → (Widget Function(Widget titleBar, Widget searchBar, Widget list, Widget closeButton, BuildContext dropDownContext)?)
buildDropDownDialog Function controls the layout of the dropdown dialog. If null, equivalent to:
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
currentPage PointerThisPlease<int>?
currentPage PointerThisPlease<int> if itemsPerPage is set, holds the page number for the search items to be displayed.
final
customPaginationDisplay → (Widget Function(Widget 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
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
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<TCBDropdownMenuItem>, int>> Function(String? keyword, String? orderBy, bool? orderAsc, List<Tuple2<String, String>>? filters, int? pageNb)?)
futureSearchFn Future<int> Function(String keyword, List<TCBDropdownMenuItem> 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
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.
no setterinherited
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<TCBDropdownMenuItem<T>>?
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
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
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
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 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.
no setterinherited
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 InputDecoration?
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
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() → _CustomDropdownTCBState<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}) 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