SearchChoices<T>.multiple constructor
Null safety
- {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 = false,
- 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( )?,
- AutovalidateMode autovalidateMode = AutovalidateMode.onUserInteraction,
- String? restorationId,
- dynamic giveMeThePop(
- Function pop
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.
itemswith child: Widget displayed ; value: any object with .toString() used to match search keyword.onChangedFunction with parameter: selectedItems not returning executed after the selection is done.selectedItemsindexes of items to be preselected.styleused for the hint if it is given is String.searchHintString|Widget|Function with no parameter returning String|Widget displayed at the top of the search dialog box.hintString|Widget|Function with no parameter returning String|Widget displayed before any value is selected or after the selection is cleared.disabledHintString|Widget|Function with no parameter returning String|Widget displayed instead of hint when the widget is displayed.iconString|Widget|Function with parameter: selectedItems returning String|Widget displayed next to the selected items or the hint if none.underlineString|Widget|Function with parameter: selectedItems returning String|Widget displayed below the selected items or the hint if none.doneButtonString|Widget|Function with parameter: selectedItems returning String|Widget displayed at the top of the search dialog box. Cannot be null in multiple selection mode.labelString|Widget|Function with parameter: selectedItems returning String|Widget displayed above the selected items or the hint if none.closeButtonString|Widget|Function with parameter: selectedItems returning String|Widget displayed at the bottom of the search dialog box.displayClearIconwhether or not to display an icon to clear the selected values.clearIconIcon to be used for clearing the selected values.iconEnabledColorColor to be used for enabled icons.iconDisabledColorColor to be used for disabled icons.iconSizefor the icons next to the selected values (icon and clearIcon).isExpandedcan be necessary to avoid pixel overflows (zebra symptom).isCaseSensitiveSearchonly used when searchFn is not specified.searchFnFunction with parameters: keyword, items returning List<int> as the list of indexes for the items to be displayed.onClearFunction with no parameter not returning executed when the clear icon is tapped.selectedValueWidgetFnFunction with parameter: item returning Widget to be used to display the selected values.keyboardTypeused for the search.validatorFunction with parameter: selectedItems returning String displayed below selected values when not valid and null when valid.displayItemFunction with parameters: item, selected returning Widget to be displayed in the search list.dialogBoxwhether the search should be displayed as a dialog box or as a menu below the selected values if any.menuConstraintsBoxConstraints used to define the zone where to display the search menu. Example: BoxConstraints.tight(Size.fromHeight(250)) . Not to be used for dialogBox = true.readOnlybool whether to let the user choose the value to select or just present the selected value if any.menuBackgroundColorColor background color of the menu whether in dialog box or menu mode.rightToLeftbool mirrors the widgets display for right to left languages defaulted to false.autofocusbool automatically focuses on the search field bringing up the keyboard defaulted to true.selectedAggregateWidgetFnFunction with parameter: list of widgets presenting selected values , returning Widget to be displayed to present the selected items.paddingdouble or EdgeInsets sets the padding around the DropdownButton, defaulted to 10.0.setOpenDialogFunction 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.buildDropDownDialogFunction controls the layout of the dropdown dialog.dropDownDialogPaddingEdgeInsets sets the padding between the screen and the dialog.searchInputDecorationInputDecoration sets the search bar decoration.itemsPerPageint if set, organizes the search list per page with the given number of items displayed per page.currentPageint ifitemsPerPageis set, holds the page number for the search items to be displayed.customPaginationDisplayWidget Function(Widget listWidget, int totalFilteredItemsNb, Function updateSearchPage) ifitemsPerPageis set, customizes the display and the handling of the pagination on the search list.futureSearchFnFutureFunction(String keyword, List itemsListToClearAndFill, int pageNb) used to search items from the network. Must return items (up to itemsPerPageif set). Must return an int with the total number of results (allows the handling of pagination).futureSearchOrderOptionsMap<String, Map<String,dynamic>> whenfutureSearchFnis 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.futureSearchFilterOptionsMap<String, Map<String, Object>> whenfutureSearchFnis 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.futureSelectedValuesList<T> contains the list of selected values in case of future search in multiple selection mode.emptyListWidgetString|Widget|Function with parameter: keyword returning String|Widget displayed instead of the list of items in case it is empty.onTapFunction 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.futureSearchRetryButtonFunction called to customize the Error - retry button displayed when there is an issue with the future search.searchDelayint in milliseconds applied before the search is initiated. This applies to future and non-future searches.fieldPresentationFnFunction returning a Widget to customize the display of the field.fieldDecorationDecoration is the decoration of the SearchChoices Widget while displaying the hints or the selected values. Should differ when selection is not valid.clearSearchIconWidget sets the icon to be used to clear the search.showDialogFnFunction allows the control of the dialog display.listValidatorFunction with parameter: List returning String displayed below selected value when not valid and null when valid.
Implementation
factory SearchChoices.multiple({
Key? key,
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,
String? Function(T?)? validator,
Function? displayItem,
bool dialogBox = true,
BoxConstraints? menuConstraints,
bool readOnly = false,
Color? menuBackgroundColor,
bool rightToLeft = false,
bool autofocus = true,
Function? selectedAggregateWidgetFn,
dynamic padding,
Function? setOpenDialog,
Widget Function(
Widget titleBar,
Widget searchBar,
Widget list,
Widget closeButton,
BuildContext dropDownContext,
)?
buildDropDownDialog,
EdgeInsets? dropDownDialogPadding,
InputDecoration? searchInputDecoration,
int? itemsPerPage,
PointerThisPlease<int>? currentPage,
Widget Function(Widget listWidget, int totalFilteredItemsNb,
Function updateSearchPage)?
customPaginationDisplay,
Future<Tuple2<List<DropdownMenuItem>, int>> Function(
String? keyword,
String? orderBy,
bool? orderAsc,
List<Tuple2<String, String>>? filters,
int? pageNb)?
futureSearchFn,
Map<String, Map<String, dynamic>>? futureSearchOrderOptions,
Map<String, Map<String, Object>>? futureSearchFilterOptions,
List<T>? futureSelectedValues,
dynamic emptyListWidget,
Function? onTap,
Function? futureSearchRetryButton,
int? searchDelay,
Widget Function(Widget fieldWidget, {bool selectionIsValid})?
fieldPresentationFn,
Decoration? fieldDecoration,
Widget? clearSearchIcon,
Future<void> Function(
BuildContext context,
Widget Function({
String searchTerms,
})
menuWidget,
String searchTerms,
)?
showDialogFn,
FormFieldSetter<T>? onSaved,
String? Function(List<dynamic>)? listValidator,
AutovalidateMode autovalidateMode = AutovalidateMode.onUserInteraction,
String? restorationId,
Function(Function pop)? giveMeThePop,
}) {
return (SearchChoices._(
key: key,
items: items,
style: style,
searchHint: searchHint,
hint: hint,
disabledHint: disabledHint,
icon: icon,
underline: underline,
iconEnabledColor: iconEnabledColor,
iconDisabledColor: iconDisabledColor,
iconSize: iconSize,
isExpanded: isExpanded,
isCaseSensitiveSearch: isCaseSensitiveSearch,
closeButton: closeButton,
displayClearIcon: displayClearIcon,
clearIcon: clearIcon,
onClear: onClear,
selectedValueWidgetFn: selectedValueWidgetFn,
keyboardType: keyboardType,
validator: validator,
label: label,
searchFn: searchFn,
multipleSelection: true,
selectedItems: selectedItems,
doneButton: doneButton,
onChanged: onChanged,
displayItem: displayItem,
dialogBox: dialogBox,
menuConstraints: menuConstraints,
readOnly: readOnly,
menuBackgroundColor: menuBackgroundColor,
rightToLeft: rightToLeft,
autofocus: autofocus,
selectedAggregateWidgetFn: selectedAggregateWidgetFn,
padding: padding,
setOpenDialog: setOpenDialog,
buildDropDownDialog: buildDropDownDialog,
dropDownDialogPadding: dropDownDialogPadding,
searchInputDecoration: searchInputDecoration,
itemsPerPage: itemsPerPage,
currentPage: currentPage,
customPaginationDisplay: customPaginationDisplay,
futureSearchFn: futureSearchFn,
futureSearchOrderOptions: futureSearchOrderOptions,
futureSearchFilterOptions: futureSearchFilterOptions,
futureSelectedValues: futureSelectedValues,
emptyListWidget: emptyListWidget,
onTap: onTap,
futureSearchRetryButton: futureSearchRetryButton,
searchDelay: searchDelay,
fieldPresentationFn: fieldPresentationFn,
fieldDecoration: fieldDecoration,
clearSearchIcon: clearSearchIcon,
showDialogFn: showDialogFn,
onSaved: onSaved,
listValidator: listValidator,
autovalidateMode: autovalidateMode,
restorationId: restorationId,
giveMeThePop: giveMeThePop,
));
}