Skip to content

Commit 3c1fd77

Browse files
committed
feat: add missing attributes for searchable_dropdown
1 parent e1c9764 commit 3c1fd77

File tree

1 file changed

+61
-47
lines changed

1 file changed

+61
-47
lines changed

packages/form_builder_extra_fields/lib/src/fields/form_builder_searchable_dropdown.dart

Lines changed: 61 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -87,41 +87,53 @@ class FormBuilderSearchableDropdown<T> extends FormBuilderField<T> {
8787

8888
final PopupProps<T> popupProps;
8989

90+
///custom dropdown clear button icon properties
91+
final IconButtonProps? clearButtonProps;
92+
93+
/// style on which to base the label
94+
final TextStyle? dropdownSearchTextStyle;
95+
96+
///custom dropdown icon button properties
97+
final IconButtonProps? dropdownButtonProps;
98+
9099
/// Creates field for selecting value(s) from a searchable list
91-
FormBuilderSearchableDropdown(
92-
{Key? key,
93-
AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
94-
bool enabled = true,
95-
FocusNode? focusNode,
96-
FormFieldSetter<T>? onSaved,
97-
FormFieldValidator<T>? validator,
98-
InputDecoration decoration = const InputDecoration(),
99-
required String name,
100-
T? initialValue,
101-
ValueChanged<T?>? onChanged,
102-
ValueTransformer<T?>? valueTransformer,
103-
VoidCallback? onReset,
104-
this.asyncItems,
105-
this.autoValidateMode,
106-
this.compareFn,
107-
this.dropdownBuilder,
108-
this.dropdownSearchDecoration,
109-
this.dropdownSearchTextAlign,
110-
this.dropdownSearchTextAlignVertical,
111-
this.filterFn,
112-
this.isFilteredOnline = false,
113-
this.itemAsString,
114-
this.items,
115-
this.onBeforeChange,
116-
this.popupOnItemAdded,
117-
this.popupOnItemRemoved,
118-
this.popupSelectionWidget,
119-
this.selectedItem,
120-
this.selectedItems = const [],
121-
this.shouldRequestFocus = false,
122-
this.showClearButton = false,
123-
this.popupProps = const PopupProps.menu()})
124-
: assert(T == String || compareFn != null),
100+
FormBuilderSearchableDropdown({
101+
Key? key,
102+
AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
103+
bool enabled = true,
104+
FocusNode? focusNode,
105+
FormFieldSetter<T>? onSaved,
106+
FormFieldValidator<T>? validator,
107+
InputDecoration decoration = const InputDecoration(),
108+
required String name,
109+
T? initialValue,
110+
ValueChanged<T?>? onChanged,
111+
ValueTransformer<T?>? valueTransformer,
112+
VoidCallback? onReset,
113+
this.asyncItems,
114+
this.autoValidateMode,
115+
this.compareFn,
116+
this.dropdownBuilder,
117+
this.dropdownSearchDecoration,
118+
this.dropdownSearchTextAlign,
119+
this.dropdownSearchTextAlignVertical,
120+
this.filterFn,
121+
this.isFilteredOnline = false,
122+
this.itemAsString,
123+
this.items,
124+
this.onBeforeChange,
125+
this.popupOnItemAdded,
126+
this.popupOnItemRemoved,
127+
this.popupSelectionWidget,
128+
this.selectedItem,
129+
this.selectedItems = const [],
130+
this.shouldRequestFocus = false,
131+
this.showClearButton = false,
132+
this.popupProps = const PopupProps.menu(),
133+
this.clearButtonProps,
134+
this.dropdownSearchTextStyle,
135+
this.dropdownButtonProps,
136+
}) : assert(T == String || compareFn != null),
125137
isMultiSelectionMode = false,
126138
dropdownBuilderMultiSelection = null,
127139
onBeforeChangeMultiSelection = null,
@@ -147,28 +159,30 @@ class FormBuilderSearchableDropdown<T> extends FormBuilderField<T> {
147159
return dropdown_search.DropdownSearch<T>(
148160
// Hack to rebuild when didChange is called
149161
key: UniqueKey(),
162+
asyncItems: asyncItems,
163+
clearButtonProps: clearButtonProps,
164+
compareFn: compareFn,
165+
enabled: state.enabled,
166+
dropdownBuilder: dropdownBuilder,
167+
dropdownButtonProps: dropdownButtonProps,
168+
dropdownSearchDecoration: state.decoration,
169+
dropdownSearchTextAlign: dropdownSearchTextAlign,
170+
dropdownSearchTextAlignVertical: dropdownSearchTextAlignVertical,
171+
dropdownSearchTextStyle: dropdownSearchTextStyle,
172+
filterFn: filterFn,
173+
isFilteredOnline: isFilteredOnline,
150174
items: items,
175+
itemAsString: itemAsString,
176+
onBeforeChange: onBeforeChange,
151177
onChanged: (value) {
152178
if (shouldRequestFocus) {
153179
state.requestFocus();
154180
}
155181
state.didChange(value);
156182
},
157-
enabled: state.enabled,
158-
autoValidateMode: autovalidateMode,
159-
compareFn: compareFn,
160-
dropdownBuilder: dropdownBuilder,
161-
dropdownSearchDecoration: state.decoration,
162-
filterFn: filterFn,
163-
isFilteredOnline: isFilteredOnline,
164-
itemAsString: itemAsString,
183+
popupProps: popupProps,
165184
selectedItem: state.value,
166185
showClearButton: showClearButton,
167-
onBeforeChange: onBeforeChange,
168-
dropdownSearchTextAlign: dropdownSearchTextAlign,
169-
dropdownSearchTextAlignVertical: dropdownSearchTextAlignVertical,
170-
asyncItems: asyncItems,
171-
popupProps: popupProps,
172186
);
173187
},
174188
);

0 commit comments

Comments
 (0)