I have a problem when i navigate to multiple pages and then show search.
More specifically, i have a product page with some details. At the bottom there is a list of similar products.
The flow is:
- open many similar products (so I navigate to the same screen using Navigator pushNamed).
- then, navigate from the las product page to the search page
- tap on search bar, open search delegate using the showSearch function
My issue is that when i tap on the search bar, then the whole widget tree is rebuilded and my app is very heavy because rebuilds the previous product pages and everything else.
2
Answers
This happens due to the general rebuild on keyboard changes(i.e: showing and hiding Keyboard).
I recommend to have a heavy operation like loading data from backend should be held on
initState
inState
withStatefullWidget
.Try to debug and understand why do you rebuild the tree. It seems to me, that you need to simplify a navigation flow.