@@ -166,15 +166,9 @@ class FormBuilderDateRangePickerState
166
166
((_formState? .initialValue? .containsKey (widget.attribute) ?? false )
167
167
? _formState.initialValue[widget.attribute]
168
168
: []);
169
- _controller = TextEditingController (
170
- text: _valueToText (),
171
- );
172
- _effectiveController.addListener (() {
173
- widget.onChanged? .call (_effectiveController.text);
174
- });
169
+ _controller = TextEditingController (text: _valueToText ());
175
170
_focusNode = FocusNode ();
176
- widget.focusNode? .addListener (_handleFocus);
177
- _focusNode? .addListener (_handleFocus);
171
+ _effectiveFocusNode? .addListener (_handleFocus);
178
172
super .initState ();
179
173
}
180
174
@@ -261,9 +255,12 @@ class FormBuilderDateRangePickerState
261
255
textDirection: widget.textDirection,
262
256
selectableDayPredicate: widget.selectableDayPredicate,
263
257
);
264
- _fieldKey.currentState.didChange (picked);
265
- _setCurrentValue (picked);
266
- _effectiveController.text = _valueToText ();
258
+ if (picked != null ) {
259
+ _fieldKey.currentState.didChange (picked);
260
+ widget.onChanged? .call (picked);
261
+ _setCurrentValue (picked);
262
+ _effectiveController.text = _valueToText ();
263
+ }
267
264
}
268
265
}
269
266
@@ -291,8 +288,9 @@ class FormBuilderDateRangePickerState
291
288
292
289
@override
293
290
void dispose () {
291
+ _focusNode? .dispose ();
294
292
_formState? .unregisterFieldKey (widget.attribute);
295
- _controller.dispose ();
293
+ _controller? .dispose ();
296
294
super .dispose ();
297
295
}
298
296
}
0 commit comments