HcSearchableDropdown<T>.single constructor

HcSearchableDropdown<T>.single({
  1. Key? key,
  2. required List<DropdownMenuItem<T>> items,
  3. Function? onChanged,
  4. required T value,
  5. TextStyle? style,
  6. dynamic searchHint,
  7. dynamic hint,
  8. dynamic disabledHint,
  9. dynamic icon = const Icon(Icons.arrow_drop_down),
  10. dynamic underline,
  11. dynamic doneButton,
  12. dynamic label,
  13. dynamic closeButton = "Close",
  14. bool displayClearIcon = true,
  15. Icon clearIcon = const Icon(Icons.clear),
  16. Color? iconEnabledColor,
  17. Color? iconDisabledColor,
  18. double iconSize = 24.0,
  19. bool isExpanded = false,
  20. bool isCaseSensitiveSearch = false,
  21. Function? searchFn,
  22. Function? onClear,
  23. Function? selectedValueWidgetFn,
  24. TextInputType keyboardType = TextInputType.text,
  25. Function? validator,
  26. bool assertUniqueValue = true,
  27. Function? displayItem,
  28. bool dialogBox = true,
  29. BoxConstraints? menuConstraints,
  30. bool readOnly = false,
  31. Color? menuBackgroundColor,
})

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.

@param items with child: Widget displayed ; value: any object with .toString() used to match search keyword. @param onChanged Function with parameter: value not returning executed after the selection is done. @param value value to be preselected. @param style used for the hint if it is given is String. @param searchHint String|Widget|Function with no parameter returning String|Widget displayed at the top of the search dialog box. @param hint String|Widget|Function with no parameter returning String|Widget displayed before any value is selected or after the selection is cleared. @param disabledHint String|Widget|Function with no parameter returning String|Widget displayed instead of hint when the widget is displayed. @param icon String|Widget|Function with parameter: value returning String|Widget displayed next to the selected item or the hint if none. @param underline String|Widget|Function with parameter: value returning String|Widget displayed below the selected item or the hint if none. @param doneButton String|Widget|Function with parameter: value returning String|Widget displayed at the top of the search dialog box. @param label String|Widget|Function with parameter: value returning String|Widget displayed above the selected item or the hint if none. @param closeButton String|Widget|Function with parameter: value returning String|Widget displayed at the bottom of the search dialog box. @param displayClearIcon whether or not to display an icon to clear the selected value. @param clearIcon Icon to be used for clearing the selected value. @param iconEnabledColor Color to be used for enabled icons. @param iconDisabledColor Color to be used for disabled icons. @param iconSize for the icons next to the selected value (icon and clearIcon). @param isExpanded can be necessary to avoid pixel overflows (zebra symptom). @param isCaseSensitiveSearch only used when searchFn is not specified. @param searchFn Function with parameters: keyword, items returning List<int> as the list of indexes for the items to be displayed. @param onClear Function with no parameter not returning executed when the clear icon is tapped. @param selectedValueWidgetFn Function with parameter: item returning Widget to be used to display the selected value. @param keyboardType used for the search. @param validator Function with parameter: value returning String displayed below selected value when not valid and null when valid. @param assertUniqueValue whether to run a consistency check of the list of items. @param displayItem Function with parameters: item, selected returning Widget to be displayed in the search list. @param dialogBox whether the search should be displayed as a dialog box or as a menu below the selected value if any. @param 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. @param readOnly bool whether to let the user choose the value to select or just present the selected value if any. @param menuBackgroundColor Color background color of the menu whether in dialog box or menu mode.

Implementation

factory HcSearchableDropdown.single({
  Key? key,
  required List<DropdownMenuItem<T>> items,
  Function? onChanged,
  required 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,
}) {
  return (HcSearchableDropdown._(
    key: key!,
    items: items,
    onChanged: onChanged!,
    value: value,
    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: false,
    doneButton: doneButton,
    displayItem: displayItem!,
    dialogBox: dialogBox,
    menuConstraints: menuConstraints!,
    readOnly: readOnly,
    menuBackgroundColor: menuBackgroundColor!,
  ));
}