1

I am working on flutter expansionTile and added different fields inside that. If I expand the expansionTile and hit submit, The form fields are submitted which are inside expansionTile. But If I collapse it and then hit submit, then only those fields values are displayed that are not collapsed.

Well for the reference here is a piece of code.


                  ExpansionTile(
                              backgroundColor: Theme.of(context)
                                  .accentColor
                                  .withOpacity(0.050),
                              title: Text(item.formName),
                              children: <Widget>[
                                FormBuilderCheckboxList(
                                  decoration:
                                      InputDecoration(labelText: item.formName),
                                  attribute: item.uniqueId,
                                  initialValue: [],
                                  // initialValue: item?.answerMultiple.map( (ans) =>ans )??[],
                                  options: item.formFieldOptions
                                      .map((opt) => FormBuilderFieldOption(
                                          value: opt.optName))
                                      .toList(),
                                ),
                              ],
                            ),


So This if I submit this checkbox field expanded then it shows the values on my DEBUG CONSOLE and if I close the ExpansionTile then its not show me any thing. Below is the output when I have expanded the Tile.

flutter: {uid_201994077147: Yes, uid_201985062316: [•   Sodium Chloride – (Road Salt, Table Salt) , •   Calcium Chloride , •    Ammonium Nitrate , Ammonium Sulfate , Sand]}

Thank you all in advance.

dan1st
  • 12,568
  • 8
  • 34
  • 67
Faran Khan
  • 1,495
  • 4
  • 14
  • 26

1 Answers1

0

Not sure if you still need this but I experienced the same issue and it seems that default behavior of ExpensionTile is removing all of its children when collapsed. There is a PR in flutter repo waiting to be merged. Until then we need to find a workaround for that. It might be keeping the state whenever value changes or when collapse changes and reinitializing its value when collapse changed again.

Ekrem KENTER
  • 316
  • 2
  • 11