From 604cea7a73474808a78da18cebd43d90926b0575 Mon Sep 17 00:00:00 2001 From: Nikodem Bernat Date: Tue, 23 Jan 2024 17:05:02 +0100 Subject: [PATCH] Add a message to an assertion --- lib/src/form_builder.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/form_builder.dart b/lib/src/form_builder.dart index 9af6b070a..040030fc5 100644 --- a/lib/src/form_builder.dart +++ b/lib/src/form_builder.dart @@ -221,7 +221,11 @@ class FormBuilderState extends State { } 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