Description
Is there an existing issue for this?
- I have searched the existing issues
Package/Plugin version
9.1.1
Platforms
- Android
- iOS
- Linux
- MacOS
- Web
- Windows
Flutter doctor
Flutter doctor
Minimal code example
Code sample (pseudocode)
class ChildWidget
{
ChildWidget(this.name)
build() => FormBuilderDropdown(name: '${this.name}_dropdown');
}
class MainWidget
{
build() => FormBuilder(child: Column(children: [ChildWidget(name: "a"), ChildWidget(name: "b")]));
}
Current Behavior
When the FormBuilder.onChanged fires, the FormBuilderState.fields collection contains ONLY the field "b_dropdown" (the last childwidget to build).
A runtime warning is output "flutter: Warning! Replacing duplicate Field for a_dropdown -- this is OK to ignore as long as the field was intentionally replaced"
Expected Behavior
When the FormBuilder.onChanged fires, the FormBuilderState.fields collection should contain BOTH the fields "a_dropdown" and "b_dropdown".
Steps To Reproduce
On any environment, create a widget tree where a child widget (in my example I've called the class ChildWidget) is used multiple times in the same form.
The child widget should contain a FormBuilder form field, but it uses some unique name (i.e passed by argument) to name the field.
It appears that the FormBuilder subsystem is perhaps using the widget tree to identify form fields, because the last ChildWidget to render will have its formfields added to the FormBuilder.fields collection, overwriting the previous ones.
Aditional information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status