uiComboBox<T> method

Widget uiComboBox<T>({
  1. required List<DropdownMenuEntry<T>> dropdownMenuEntries,
  2. Key? key,
  3. bool enabled = true,
  4. bool enableFilter = false,
  5. bool enableSearch = true,
  6. String? errorText,
  7. double? menuHeight,
  8. String? helperText,
  9. String? hintText,
  10. T? initialSelection,
  11. Widget? label,
  12. dynamic leadingIcon,
  13. void onSelected(
    1. T?
    )?,
  14. int? searchCallback(
    1. List<DropdownMenuEntry<T>>,
    2. String
    )?,
  15. DropdownMenuThemeData? style,
  16. dynamic trailingIcon,
  17. double? width,
})

Creates a customizable combo box drop down with the ability to implement a search box to filter the combo box.

Implementation

Widget uiComboBox<T>({
  required List<DropdownMenuEntry<T>> dropdownMenuEntries,
  Key? key,
  bool enabled = true,
  bool enableFilter = false,
  bool enableSearch = true,
  String? errorText,
  double? menuHeight,
  String? helperText,
  String? hintText,
  T? initialSelection,
  Widget? label,
  dynamic leadingIcon,
  void Function(T?)? onSelected,
  int? Function(List<DropdownMenuEntry<T>>, String)? searchCallback,
  DropdownMenuThemeData? style,
  dynamic trailingIcon,
  double? width,
}) {
  assert(
    leadingIcon == null || leadingIcon is IconData || leadingIcon is Image,
    "leadingIcon can only be an Image, IconData, or null type",
  );
  assert(
    trailingIcon == null || trailingIcon is IconData || trailingIcon is Image,
    "trailingIcon can only be an Image, IconData, or null type",
  );

  final menu = DropdownMenu<T>(
    dropdownMenuEntries: dropdownMenuEntries,
    enabled: enabled,
    enableFilter: enableFilter,
    enableSearch: enableSearch,
    errorText: errorText,
    helperText: helperText,
    hintText: hintText,
    initialSelection: initialSelection,
    label: label,
    leadingIcon: leadingIcon is IconData ? Icon(leadingIcon) : leadingIcon,
    menuHeight: menuHeight,
    onSelected: onSelected,
    searchCallback: searchCallback,
    trailingIcon:
        trailingIcon is IconData ? Icon(trailingIcon) : trailingIcon,
    width: width,
  );
  return style != null
      ? DropdownMenuTheme(
          data: style,
          child: menu,
        )
      : menu;
}