Closed lucaseduoli closed 1 year ago
Your StreamBuilder causes the Accordion to be rebuilt every time and therefore doing its opening sequence. You should only update data (if any) inside an AccordionSection, not rebuild the whole Accordion. See #47 #46 #42 #31 #21
It's a very common use case. I have faced an issue due to this in mobile browser. In my case I have a MediaQuery call in the parent. In my accordion section there is a textFormField (used for searching). When I tap it the keyboard gets launched. Because of the MediaQuery call after launching the keyboard it recalculates the hight and build the widget again. As a result the accordion also gets rebuilt and the textFormField goes out of focus. Which then makes the keyboard disappear.
Then I used the ExpansionPanelList and it worked. The text field is not losing the focus in that case.
In general, in Flutter, rebuilds are quite common, the component should maintain the state across rebuilds.
@PT10 I just tried putting a TextFromField in an AccordionSection and it works fine. Of course, if you wrap the whole Accordion in another widget that changes the layout then this might be a problem. However, combining all your requirements (textfield & wrapped) is probably out of the scope of this widget. You might want to try setting sectionAnimation
to false -- maybe that helps.
Hello, I have a code that generates the Accordion list with a StreamBuilder, but when it updates something, the entire accordion gets redrawed and, because of that, the open sections close. I have tried to make a external state, setting isOpen on the sections, but when the component gets redrawed, the opening animation is triggered. How can I make this work?