Skip to content

Commit 7c1619c

Browse files
committed
Fixed error 'The getter 'initialValue' was called on null' if no FormBuiderState ancestry. Closes #364
1 parent 919955f commit 7c1619c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/src/fields/form_builder_dropdown.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ class _FormBuilderDropdownState<T> extends State<FormBuilderDropdown<T>> {
8383
_formState = FormBuilder.of(context);
8484
_formState?.registerFieldKey(widget.attribute, _fieldKey);
8585
_initialValue = widget.initialValue ??
86-
(_formState.initialValue.containsKey(widget.attribute)
87-
? _formState.initialValue[widget.attribute]
86+
((_formState?.initialValue?.containsKey(widget.attribute) ?? false)
87+
? _formState?.initialValue[widget.attribute]
8888
: null);
8989
super.initState();
9090
}

0 commit comments

Comments
 (0)