FormBuilderSearchableDropdown<T> constructor

FormBuilderSearchableDropdown<T>({
  1. Key? key,
  2. AutovalidateMode? autovalidateMode,
  3. bool enabled = true,
  4. FocusNode? focusNode,
  5. FormFieldSetter<T>? onSaved,
  6. FormFieldValidator<T>? validator,
  7. InputDecoration decoration = const InputDecoration(),
  8. required String name,
  9. T? initialValue,
  10. ValueChanged<T?>? onChanged,
  11. ValueTransformer<T?>? valueTransformer,
  12. VoidCallback? onReset,
  13. DropdownSearchOnFind<T>? asyncItems,
  14. AutovalidateMode? autoValidateMode,
  15. DropdownSearchCompareFn<T>? compareFn,
  16. DropdownSearchBuilder<T>? dropdownBuilder,
  17. InputDecoration? dropdownSearchDecoration,
  18. TextAlign? dropdownSearchTextAlign,
  19. TextAlignVertical? dropdownSearchTextAlignVertical,
  20. DropdownSearchFilterFn<T>? filterFn,
  21. DropdownSearchItemAsString<T>? itemAsString,
  22. List<T> items = const [],
  23. BeforeChange<T>? onBeforeChange,
  24. OnItemAdded<T>? popupOnItemAdded,
  25. OnItemRemoved<T>? popupOnItemRemoved,
  26. DropdownSearchPopupItemBuilder<T>? popupSelectionWidget,
  27. T? selectedItem,
  28. List<T> selectedItems = const [],
  29. PopupProps<T> popupProps = const PopupProps.menu(showSearchBox: true, fit: FlexFit.loose),
  30. ClearButtonProps? clearButtonProps,
  31. TextStyle? dropdownSearchTextStyle,
  32. DropdownButtonProps? dropdownButtonProps,
})

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

Implementation

FormBuilderSearchableDropdown({
  super.key,
  super.autovalidateMode,
  super.enabled,
  super.focusNode,
  super.onSaved,
  super.validator,
  super.decoration,
  required super.name,
  super.initialValue,
  super.onChanged,
  super.valueTransformer,
  super.onReset,
  this.asyncItems,
  this.autoValidateMode,
  this.compareFn,
  this.dropdownBuilder,
  this.dropdownSearchDecoration,
  this.dropdownSearchTextAlign,
  this.dropdownSearchTextAlignVertical,
  this.filterFn,
  // this.isFilteredOnline = false,
  this.itemAsString,
  this.items = const [],
  this.onBeforeChange,
  this.popupOnItemAdded,
  this.popupOnItemRemoved,
  this.popupSelectionWidget,
  this.selectedItem,
  this.selectedItems = const [],
  this.popupProps = const PopupProps.menu(
    showSearchBox: true,
    fit: FlexFit.loose,
  ),
  this.clearButtonProps,
  this.dropdownSearchTextStyle,
  this.dropdownButtonProps,
})  : assert(T == String || compareFn != null),
      isMultiSelectionMode = false,
      dropdownBuilderMultiSelection = null,
      onBeforeChangeMultiSelection = null,
      onSavedMultiSelection = null,
      onChangedMultiSelection = null,
      popupValidationMultiSelectionWidget = null,
      popupCustomMultiSelectionWidget = null,
      super(
        builder: (FormFieldState<T?> field) {
          final state = field as FormBuilderSearchableDropdownState<T>;
          return DropdownSearch<T>(
            // Hack to rebuild when didChange is called
            asyncItems: asyncItems,
            clearButtonProps: clearButtonProps ?? const ClearButtonProps(),
            compareFn: compareFn,
            enabled: state.enabled,
            dropdownBuilder: dropdownBuilder,
            dropdownButtonProps:
                dropdownButtonProps ?? const DropdownButtonProps(),
            dropdownDecoratorProps: DropDownDecoratorProps(
              dropdownSearchDecoration: state.decoration,
              textAlign: dropdownSearchTextAlign,
              textAlignVertical: dropdownSearchTextAlignVertical,
              baseStyle: dropdownSearchTextStyle,
            ),
            filterFn: filterFn,
            items: items,
            itemAsString: itemAsString,
            onBeforeChange: onBeforeChange,
            onChanged: (value) {
              state.didChange(value);
            },
            popupProps: popupProps,
            selectedItem: state.value,
          );
        },
      );