SearchChoices<T>.multiple constructor
SearchChoices<T>.multiple ({
- Key? key,
- List<
DropdownMenuItem< ? items,T> > - 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,
- String? validator(
- T?
- Function? displayItem,
- bool dialogBox = true,
- bool readOnly = false,
- bool? rightToLeft,
- bool autofocus = true,
- Function? selectedAggregateWidgetFn,
- dynamic padding,
- Function? setOpenDialog,
- Widget buildDropDownDialog(
- Widget titleBar,
- Widget searchBar,
- Widget list,
- Widget closeButton,
- BuildContext dropDownContext,
- EdgeInsets? dropDownDialogPadding,
- InputDecoration? searchInputDecoration,
- int? itemsPerPage,
- PointerThisPlease<
int> ? currentPage, - Widget customPaginationDisplay()?,
- Future<
Tuple2< futureSearchFn()?,List< >DropdownMenuItem> , int> - Map<
String, Map< ? futureSearchOrderOptions,String, dynamic> > - Map<
String, Map< ? futureSearchFilterOptions,String, Object> > - List<
T> ? futureSelectedValues, - dynamic emptyListWidget,
- Function? onTap,
- Function? futureSearchRetryButton,
- int? searchDelay,
- Widget fieldPresentationFn(})?,
- Decoration? fieldDecoration,
- Widget? clearSearchIcon,
- Future<
void> showDialogFn(- BuildContext context,
- String searchTerms
- FormFieldSetter<
T> ? onSaved, - String? listValidator(
- List<
T?>
- List<
- AutovalidateMode autovalidateMode = AutovalidateMode.onUserInteraction,
- String? restorationId,
- dynamic giveMeThePop(
- Function pop
- Widget buildFutureFilterOrOrderButton({})?,
- Widget searchResultDisplayFn({
- required Widget displayItem(
- DropdownMenuItem item,
- bool isItemSelected
- required Widget emptyListWidget,
- required void itemTapped(),
- required List<
Tuple3< itemsToDisplay,int, DropdownMenuItem, bool> > - required ScrollController scrollController,
- required bool thumbVisibility,
- required Widget displayItem(
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.
- items with child: Widget displayed ; value: any object with .toString() used to match search keyword.
- onChanged Function with parameter: selectedItems not returning executed after the selection is done.
- selectedItems indexes of items to be preselected.
- style used for the hint if it is given is String.
- searchHint String|Widget|Function with no parameter returning String|Widget displayed at the top of the search dialog box.
- hint String|Widget|Function with no parameter returning String|Widget displayed before any value is selected or after the selection is cleared.
- disabledHint String|Widget|Function with no parameter returning String|Widget displayed instead of hint when the widget is displayed.
- icon String|Widget|Function with parameter: selectedItems returning String|Widget displayed next to the selected items or the hint if none.
- underline String|Widget|Function with parameter: selectedItems returning String|Widget displayed below the selected items or the hint if none.
- doneButton String|Widget|Function with parameter: selectedItems returning String|Widget displayed at the top of the search dialog box. Cannot be null in multiple selection mode.
- label String|Widget|Function with parameter: selectedItems returning String|Widget displayed above the selected items or the hint if none.
- closeButton String|Widget|Function with parameter: selectedItems returning String|Widget displayed at the bottom of the search dialog box.
- displayClearIcon whether or not to display an icon to clear the selected values.
- clearIcon Icon to be used for clearing the selected values.
- iconEnabledColor Color to be used for enabled icons.
- iconDisabledColor Color to be used for disabled icons.
- iconSize for the icons next to the selected values (icon and clearIcon).
- isExpanded can be necessary to avoid pixel overflows (zebra symptom).
- isCaseSensitiveSearch only used when searchFn is not specified.
- searchFn Function with parameters: keyword, items returning List<int> as the list of indexes for the items to be displayed.
- onClear Function with no parameter not returning executed when the clear icon is tapped.
- selectedValueWidgetFn Function with parameter: item returning Widget to be used to display the selected values.
- keyboardType used for the search.
- validator Function with parameter: selectedItems returning String displayed below selected values when not valid and null when valid.
- displayItem Function with parameters: item, selected returning Widget to be displayed in the search list.
- dialogBox whether the search should be displayed as a dialog box or as a menu below the selected values if any.
- 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.
- readOnly bool whether to let the user choose the value to select or just present the selected value if any.
- menuBackgroundColor Color background color of the menu whether in dialog box or menu mode.
- rightToLeft bool mirrors the widgets display for right to left languages defaulted to false.
- autofocus bool automatically focuses on the search field bringing up the keyboard defaulted to true.
- selectedAggregateWidgetFn Function with parameter: list of widgets presenting selected values , returning Widget to be displayed to present the selected items.
- padding double or EdgeInsets sets the padding around the DropdownButton, defaulted to 10.0.
- 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.
- buildDropDownDialog Function controls the layout of the dropdown dialog.
- dropDownDialogPadding EdgeInsets sets the padding between the screen and the dialog.
- searchInputDecoration InputDecoration sets the search bar decoration.
- itemsPerPage int if set, organizes the search list per page with the given number of items displayed per page.
- currentPage int if itemsPerPage is set, holds the page number for the search items to be displayed.
- 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.
- futureSearchFn Future
- 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.
- 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.
- futureSelectedValues List<T> contains the list of selected values in case of future search in multiple selection mode.
- emptyListWidget String|Widget|Function with parameter: keyword returning String|Widget displayed instead of the list of items in case it is empty.
- 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.
- futureSearchRetryButton Function called to customize the Error - retry button displayed when there is an issue with the future search.
- searchDelay int in milliseconds applied before the search is initiated. This applies to future and non-future searches.
- fieldPresentationFn Function returning a Widget to customize the display of the field.
- fieldDecoration Decoration is the decoration of the SearchChoices Widget while displaying the hints or the selected values. Should differ when selection is not valid.
- clearSearchIcon Widget sets the icon to be used to clear the search. showDialogFn Function allows the control of the dialog display.
- listValidator Function with parameter: List returning String displayed below selected value when not valid and null when valid.
- buildFutureFilterOrOrderButton Function to customize the order and
filter button in case of future search. Where:
**
filter
is true if building filter button and false while building order button. **nbFilters
is set to the number of filters applied if any. **orderAsc
true when the applied order is ascending. **orderBy
is the string by which the search is sorted. - searchResultDisplayFn to customize the display of the search result items within the dialog or menu.
Implementation
SearchChoices.multiple({
Key? key,
this.items,
this.onChanged,
this.selectedItems = const [],
this.style,
this.searchHint,
this.hint,
this.disabledHint,
this.icon = const Icon(Icons.arrow_drop_down),
this.underline,
this.doneButton = "Done",
this.label,
this.closeButton = "Close",
this.displayClearIcon = true,
this.clearIcon = const Icon(Icons.clear),
this.iconEnabledColor,
this.iconDisabledColor,
this.iconSize = 24.0,
this.isExpanded = false,
this.isCaseSensitiveSearch = false,
this.searchFn,
this.onClear,
this.selectedValueWidgetFn,
this.keyboardType = TextInputType.text,
this.validator,
this.displayItem,
this.dialogBox = true,
this.menuConstraints,
this.readOnly = false,
this.menuBackgroundColor,
this.rightToLeft,
this.autofocus = true,
this.selectedAggregateWidgetFn,
this.padding,
this.setOpenDialog,
this.buildDropDownDialog,
this.dropDownDialogPadding,
this.searchInputDecoration,
this.itemsPerPage,
this.currentPage,
this.customPaginationDisplay,
this.futureSearchFn,
this.futureSearchOrderOptions,
this.futureSearchFilterOptions,
this.futureSelectedValues,
this.emptyListWidget,
this.onTap,
this.futureSearchRetryButton,
this.searchDelay,
this.fieldPresentationFn,
this.fieldDecoration,
this.clearSearchIcon,
this.showDialogFn,
this.onSaved,
this.listValidator,
this.autovalidateMode = AutovalidateMode.onUserInteraction,
this.restorationId,
this.giveMeThePop,
this.buildFutureFilterOrOrderButton,
this.searchResultDisplayFn,
}) : multipleSelection = true,
value = null,
super(
key: key,
builder: (FormFieldState<dynamic> state) {
_SearchChoicesState<T> sCState = state as _SearchChoicesState<T>;
return (sCState.buildWidget(sCState.context));
},
onSaved: onSaved,
validator: validator,
initialValue: null,
enabled: (items?.isNotEmpty ?? false || futureSearchFn != null) &&
(onChanged != null || onChanged is Function),
autovalidateMode: autovalidateMode,
restorationId: restorationId,
) {
checkPreconditions();
}