I'm using flutter_form_builder and I want to build a dynamic form, such as answering Yes or No on a Widget and then having another Widget pop-up right below it.
For instance: "Did the patient eat anything?" Yes/No. If yes, show a widget with checkboxes "What did they eat?" Rice, pizza, etc.
The problem is that FormBuilder is throwing warnings when I'm changing the diuresis Radio: I/flutter (21285): Warning! Replacing duplicate Field for activities -- this is OK to ignore as long as the field was intentionally replaced I/flutter (21285): Warning! Replacing duplicate Field for elimination -- this is OK to ignore as long as the field was intentionally replaced I/flutter (21285): Warning! Ignoring Field unregistration for elimination -- this is OK to ignore as long as the field was intentionally replaced
The main issue: So, what happens on the UI is. Let's say I select "Sim" for the "elimination" card and then I change my selection on the "diuresis" card, then it throws the error above, the screen rebuilds and the elimination card appears unselected.
My code is below. (HMClickableCard is just a widget that has a card and implements FormBuilderRadioGroup inside it)
Container(
child: HMClickableCard(
options: ["Sim", "Não"],
label: "Diurese",
name: "diuresis",
icon: Icons.bathroom,
iconSize: 30,
onChanged: (option) {
_fbKey.currentState?.save();
setState(() {
switch (option) {
case "Sim":
_diuresis = true;
break;
case "Não":
_diuresis = false;
break;
}
});
}),
),
Container(
child: FormBuilderCheckboxGroup(
name: "diuresisAspect",
options: [
FormBuilderFieldOption(value: "Clara"),
FormBuilderFieldOption(value: "Amarelo Ouro"),
FormBuilderFieldOption(value: "Avermelhada"),
FormBuilderFieldOption(value: "Odor forte"),
FormBuilderFieldOption(value: "Queixa de dor ao urinar"),
],
decoration: InputDecoration(
labelText: "Aspecto da diurese",
labelStyle:
TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
)),
Container(
child: HMClickableCard(
options: ["Sim", "Não"],
label: "Eliminação Intestinal",
name: "elimination",
icon: Icons.ac_unit,
iconSize: 30,
onChanged: (_option) {
_fbKey.currentState?.save();
setState(() {
switch (_option) {
case "Sim":
_intestinalElimination = true;
break;
case "Não":
_intestinalElimination = false;
break;
}
});
},
)),
Container(
child: FormBuilderCheckboxGroup(
name: "eliminationAspect",
options: [
FormBuilderFieldOption(value: "Bolinhas"),
FormBuilderFieldOption(
value: "Moldadas (forma de salsicha)"),
FormBuilderFieldOption(value: "Pastosa"),
FormBuilderFieldOption(value: "Líquida")
],
decoration: InputDecoration(
labelText: "Aspecto da eliminação intestinal:",
labelStyle:
TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
)),
Does anybody know how to solve this? I googled and could only find things related to different keys (I'm only using a GlobalKey for the entire form) or same name for the FormFields (which as you can see is not the case)