Skip to content

Commit 40cfc4b

Browse files
committed
Check that _typeAheadController is non-null before trying to dispose. Closes #256
1 parent 49eaba1 commit 40cfc4b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/src/fields/form_builder_typeahead.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ class _FormBuilderTypeAheadState<T> extends State<FormBuilderTypeAhead<T>> {
206206
void dispose() {
207207
_formState?.unregisterFieldKey(widget.attribute);
208208
if (widget.controller == null) {
209-
_typeAheadController.dispose();
209+
_typeAheadController?.dispose();
210210
} else {
211-
_typeAheadController.removeListener(_handleStringOnChanged);
211+
_typeAheadController?.removeListener(_handleStringOnChanged);
212212
}
213213
if (widget.textFieldConfiguration.focusNode == null) {
214214
_typeAheadFocusNode?.dispose();

0 commit comments

Comments
 (0)