Skip to content

Commit

Permalink
Merge pull request #1355 from n-bernat/fix/unregister-field-assert-me…
Browse files Browse the repository at this point in the history
…ssage

Add a message to an assertion
  • Loading branch information
deandreamatias authored Jan 24, 2024
2 parents 50f5645 + 604cea7 commit 294f63f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/src/form_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ class FormBuilderState extends State<FormBuilder> {
}

void unregisterField(String name, FormBuilderFieldState field) {
assert(_fields.containsKey(name));
assert(
_fields.containsKey(name),
'Failed to unregister a field. Make sure that all field names in a form are unique.',
);

// Only remove the field when it is the one registered. It's possible that
// the field is replaced (registerField is called twice for a given name)
// before unregisterField is called for the name, so just emit a warning
Expand Down

0 comments on commit 294f63f

Please sign in to comment.