Skip to content

Commit c22c4f9

Browse files
committed
Minor code reorganization.
1 parent 1cb24e5 commit c22c4f9

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lib/src/fields/form_builder_dropdown.dart

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ class FormBuilderDropdown<T> extends FormBuilderField<T> {
229229
// DropdownButtonFormField
230230
// TextFormField
231231

232+
void changeValue(T value) {
233+
state.requestFocus();
234+
state.didChange(value);
235+
}
236+
232237
return InputDecorator(
233238
decoration: state.decoration().copyWith(
234239
floatingLabelBehavior: hint == null
@@ -260,9 +265,8 @@ class FormBuilderDropdown<T> extends FormBuilderField<T> {
260265
icon: icon,
261266
iconDisabledColor: iconDisabledColor,
262267
iconEnabledColor: iconEnabledColor,
263-
onChanged: enabled
264-
? (value) => _changeValue<T>(state, value)
265-
: null,
268+
onChanged:
269+
enabled ? (value) => changeValue(value) : null,
266270
onTap: onTap,
267271
focusNode: state.effectiveFocusNode,
268272
autofocus: autofocus,
@@ -277,7 +281,7 @@ class FormBuilderDropdown<T> extends FormBuilderField<T> {
277281
const VerticalDivider(),
278282
InkWell(
279283
child: clearIcon,
280-
onTap: () => _changeValue<T>(state, null),
284+
onTap: () => changeValue(null),
281285
),
282286
]
283287
],
@@ -286,11 +290,6 @@ class FormBuilderDropdown<T> extends FormBuilderField<T> {
286290
},
287291
);
288292

289-
static void _changeValue<T>(_FormBuilderDropdownState<T> state, T value) {
290-
state.requestFocus();
291-
state.didChange(value);
292-
}
293-
294293
@override
295294
_FormBuilderDropdownState<T> createState() => _FormBuilderDropdownState<T>();
296295
}

0 commit comments

Comments
 (0)