FormBuilderSearchableDropdown<T> constructor Null safety

FormBuilderSearchableDropdown<T>(
  1. {Key? key,
  2. required String name,
  3. FormFieldValidator<T>? validator,
  4. T? initialValue,
  5. InputDecoration decoration = const InputDecoration(),
  6. ValueChanged<T?>? onChanged,
  7. ValueTransformer<T?>? valueTransformer,
  8. bool enabled = true,
  9. FormFieldSetter<T>? onSaved,
  10. AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  11. VoidCallback? onReset,
  12. FocusNode? focusNode,
  13. required List<T>? items,
  14. Mode mode = dropdown_search.Mode.MENU,
  15. bool isFilteredOnline = false,
  16. Widget? popupTitle,
  17. T? selectedItem,
  18. DropdownSearchOnFind<T>? onFind,
  19. DropdownSearchBuilder<T>? dropdownBuilder,
  20. DropdownSearchPopupItemBuilder<T>? popupItemBuilder,
  21. bool showSearchBox = true,
  22. bool showClearButton = false,
  23. Color? popupBackgroundColor,
  24. double? maxHeight,
  25. DropdownSearchFilterFn<T>? filterFn,
  26. DropdownSearchItemAsString<T>? itemAsString,
  27. DropdownSearchCompareFn<T>? compareFn,
  28. EmptyBuilder? emptyBuilder,
  29. LoadingBuilder? loadingBuilder,
  30. ErrorBuilder? errorBuilder,
  31. double? dialogMaxWidth,
  32. Widget? clearButton,
  33. Widget? dropDownButton,
  34. bool dropdownBuilderSupportsNullItem = false,
  35. ShapeBorder? popupShape,
  36. DropdownSearchPopupItemEnabled<T>? popupItemDisabled,
  37. Color? popupBarrierColor,
  38. IconButtonBuilder? clearButtonBuilder,
  39. IconButtonBuilder? dropdownButtonBuilder,
  40. FavoriteItemsBuilder<T>? favoriteItemBuilder,
  41. FavoriteItems<T>? favoriteItems,
  42. BeforeChange<T>? onBeforeChange,
  43. MainAxisAlignment? favoriteItemsAlignment = MainAxisAlignment.start,
  44. VoidCallback? onPopupDismissed,
  45. Duration? searchDelay,
  46. bool showAsSuffixIcons = false,
  47. bool showFavoriteItems = false,
  48. List<T> selectedItems = const [],
  49. ValueChanged<List<T>>? onChangedMultiSelection,
  50. DropdownSearchBuilderMultiSelection<T>? dropdownBuilderMultiSelection,
  51. bool showSelectedItems = false,
  52. InputDecoration? dropdownSearchDecoration,
  53. TextStyle? dropdownSearchBaseStyle,
  54. TextAlign? dropdownSearchTextAlign,
  55. TextAlignVertical? dropdownSearchTextAlignVertical,
  56. AutovalidateMode? autoValidateMode,
  57. FormFieldSetter<List<T>>? onSavedMultiSelection,
  58. double? clearButtonSplashRadius,
  59. double? dropdownButtonSplashRadius,
  60. BeforeChangeMultiSelection<T>? onBeforeChangeMultiSelection,
  61. PopupSafeAreaProps popupSafeArea = const PopupSafeAreaProps(),
  62. TextFieldProps? searchFieldProps,
  63. ScrollbarProps? scrollbarProps,
  64. bool popupBarrierDismissible = true,
  65. bool isMultiSelectionMode = false,
  66. OnItemAdded<T>? popupOnItemAdded,
  67. OnItemRemoved<T>? popupOnItemRemoved,
  68. DropdownSearchPopupItemBuilder<T>? popupSelectionWidget,
  69. ValidationMultiSelectionBuilder<T?>? popupValidationMultiSelectionWidget,
  70. double popupElevation = 0,
  71. PositionCallback? positionCallback}
)

Creates field for selecting value(s) from a searchable list

Implementation

FormBuilderSearchableDropdown({
  Key? key,
  //From Super
  required String name,
  FormFieldValidator<T>? validator,
  T? initialValue,
  InputDecoration decoration = const InputDecoration(),
  ValueChanged<T?>? onChanged,
  ValueTransformer<T?>? valueTransformer,
  bool enabled = true,
  FormFieldSetter<T>? onSaved,
  AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  VoidCallback? onReset,
  FocusNode? focusNode,
  required this.items,
  this.mode = dropdown_search.Mode.MENU,
  this.isFilteredOnline = false,
  this.popupTitle,
  this.selectedItem,
  this.onFind,
  this.dropdownBuilder,
  this.popupItemBuilder,
  this.showSearchBox = true,
  this.showClearButton = false,
  this.popupBackgroundColor,
  this.maxHeight,
  this.filterFn,
  this.itemAsString,
  this.compareFn,
  this.emptyBuilder,
  this.loadingBuilder,
  this.errorBuilder,
  this.dialogMaxWidth,
  this.clearButton,
  this.dropDownButton,
  this.dropdownBuilderSupportsNullItem = false,
  this.popupShape,
  this.popupItemDisabled,
  this.popupBarrierColor,
  this.clearButtonBuilder,
  this.dropdownButtonBuilder,
  this.favoriteItemBuilder,
  this.favoriteItems,
  this.onBeforeChange,
  this.favoriteItemsAlignment = MainAxisAlignment.start,
  this.onPopupDismissed,
  // this.searchBoxController,
  this.searchDelay,
  this.showAsSuffixIcons = false,
  this.showFavoriteItems = false,
  this.selectedItems = const [],
  this.onChangedMultiSelection,
  this.dropdownBuilderMultiSelection,
  this.showSelectedItems = false,
  this.dropdownSearchDecoration,
  this.dropdownSearchBaseStyle,
  this.dropdownSearchTextAlign,
  this.dropdownSearchTextAlignVertical,
  this.autoValidateMode,
  this.onSavedMultiSelection,
  this.clearButtonSplashRadius,
  this.dropdownButtonSplashRadius,
  this.onBeforeChangeMultiSelection,
  this.popupSafeArea = const PopupSafeAreaProps(),
  this.searchFieldProps,
  this.scrollbarProps,
  this.popupBarrierDismissible = true,
  this.isMultiSelectionMode = false,
  this.popupOnItemAdded,
  this.popupOnItemRemoved,
  this.popupSelectionWidget,
  this.popupValidationMultiSelectionWidget,
  this.popupElevation = 0,
  this.positionCallback,
}) : super(
        key: key,
        initialValue: initialValue,
        name: name,
        validator: validator,
        valueTransformer: valueTransformer,
        onChanged: onChanged,
        autovalidateMode: autovalidateMode,
        onSaved: onSaved,
        enabled: enabled,
        onReset: onReset,
        decoration: decoration,
        focusNode: focusNode,
        builder: (FormFieldState<T?> field) {
          final state = field as _FormBuilderSearchableDropdownState<T>;

          return dropdown_search.DropdownSearch<T>(
            key: ValueKey(state.value),
            // Hack to rebuild when didChange is called
            items: items,
            maxHeight: 300,
            onFind: onFind,
            onChanged: (val) {
              state.requestFocus();
              state.didChange(val);
            },
            showSearchBox: showSearchBox,
            enabled: state.enabled,

            autoValidateMode: autovalidateMode,
            clearButton: clearButton,
            compareFn: compareFn,
            dialogMaxWidth: dialogMaxWidth,
            dropdownBuilder: dropdownBuilder,
            dropdownBuilderSupportsNullItem: dropdownBuilderSupportsNullItem,
            dropDownButton: dropDownButton,
            dropdownSearchDecoration: state.decoration,
            emptyBuilder: emptyBuilder,
            errorBuilder: errorBuilder,
            filterFn: filterFn,
            isFilteredOnline: isFilteredOnline,
            itemAsString: itemAsString,
            loadingBuilder: loadingBuilder,
            popupBackgroundColor: popupBackgroundColor,
            mode: mode,
            popupBarrierColor: popupBarrierColor,
            popupItemBuilder: popupItemBuilder,
            popupItemDisabled: popupItemDisabled,
            popupShape: popupShape,
            popupTitle: popupTitle,
            selectedItem: state.value,
            showClearButton: showClearButton,
            clearButtonBuilder: clearButtonBuilder,
            dropdownButtonBuilder: dropdownButtonBuilder,
            favoriteItemBuilder: favoriteItemBuilder,
            favoriteItems: favoriteItems,
            onBeforeChange: onBeforeChange,
            favoriteItemsAlignment: favoriteItemsAlignment,
            onPopupDismissed: onPopupDismissed,
            searchDelay: searchDelay,
            showAsSuffixIcons: showAsSuffixIcons,
            showFavoriteItems: showFavoriteItems,
            clearButtonSplashRadius: clearButtonSplashRadius,
            dropdownButtonSplashRadius: dropdownButtonSplashRadius,
            dropdownSearchBaseStyle: dropdownSearchBaseStyle,
            dropdownSearchTextAlign: dropdownSearchTextAlign,
            dropdownSearchTextAlignVertical: dropdownSearchTextAlignVertical,
            // onSaved: onSaved,
            popupBarrierDismissible: popupBarrierDismissible,
            popupElevation: popupElevation,
            popupSafeArea: popupSafeArea,
            scrollbarProps: scrollbarProps,
            searchFieldProps: searchFieldProps,
            showSelectedItems: showSelectedItems,
            positionCallback: positionCallback,
          );
        },
      );