I\'m trying to get ExpansionTile
to collapse after I choose an item, but it does not close the list that was opened.
I tried to use the onExpansio
I found a simple solution. Just add a global key to the ExpansionTile widget and it will work as intended.
ExpansionTile(
key: GlobalKey(),
title: Text(title),
children: listTiles,
...
)
Not sure why this works, but my guess is that adding a key somehow forces the ExpansionTile widget to rebuild every time title is changed in setState, therefore return to its initial (collapsed) state.