Unregister Field from State
7.7.0 version:
I am getting _fields.containsKey(name) after removing Text Field from a List
I have dynamic count of Cells (each cell contains one TextField) in my Scroll View, the User is also able to remove Cells. After deleting cells and dismiss the screen, I think the disposer / deinit part is taking over and iterate each _field and tried to unregisterField.
By doing that, I am getting:
════════ Exception caught by widgets library ═══════════════════════════════════ The following assertion was thrown while finalizing the widget tree: 'package:flutter_form_builder/src/form_builder.dart': Failed assertion: line 194 pos 12: '_fields.containsKey(name)': is not true.
Idea
I could not find any Documentation how I can unregister Fields by my self after removing the Cell, I can call formKey.currentState?.unregisterField but I don't know how I can get access to FormBuilderFieldState.
Any help?
SDK https://github.com/flutter-form-builder-ecosystem/flutter_form_builder
FlutterFormBuilder rapresents field states in a map inside the
currentState, you can access the currentState from the form key that you are using (the same state where you access the unregister function. This is an exampleHope this answer can help you!