FormBuilderSearchableDropdown<T> constructor
FormBuilderSearchableDropdown<T> ({
- Key? key,
- AutovalidateMode? autovalidateMode,
- bool enabled = true,
- FocusNode? focusNode,
- FormFieldSetter<
T> ? onSaved, - FormFieldValidator<
T> ? validator, - InputDecoration decoration = const InputDecoration(),
- required String name,
- T? initialValue,
- ValueChanged<
T?> ? onChanged, - ValueTransformer<
T?> ? valueTransformer, - VoidCallback? onReset,
- DropdownSearchOnFind<
T> ? asyncItems, - AutovalidateMode? autoValidateMode,
- DropdownSearchCompareFn<
T> ? compareFn, - DropdownSearchBuilder<
T> ? dropdownBuilder, - InputDecoration? dropdownSearchDecoration,
- TextAlign? dropdownSearchTextAlign,
- TextAlignVertical? dropdownSearchTextAlignVertical,
- DropdownSearchFilterFn<
T> ? filterFn, - DropdownSearchItemAsString<
T> ? itemAsString, - List<
T> items = const [], - BeforeChange<
T> ? onBeforeChange, - OnItemAdded<
T> ? popupOnItemAdded, - OnItemRemoved<
T> ? popupOnItemRemoved, - DropdownSearchPopupItemBuilder<
T> ? popupSelectionWidget, - T? selectedItem,
- List<
T> selectedItems = const [], - PopupProps<
T> popupProps = const PopupProps.menu(showSearchBox: true, fit: FlexFit.loose), - ClearButtonProps? clearButtonProps,
- TextStyle? dropdownSearchTextStyle,
- 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,
);
},
);