StarBattle08
StarBattle08

Reputation: 55

Flutter how to call initState() inside PageView for every pages (even if the page already loaded before)

I'm having a problem where initState() won't get called inside a PageView if the page was loaded before. And dispose() is also not getting called when changing pages. I have set keepPage = false but it still won't work.

Upvotes: 0

Views: 843

Answers (1)

ritik kumar srivastava
ritik kumar srivastava

Reputation: 550

This is because the PageView doesn't rebuild the page on changing the page. The solution to this is to use PageView.builder. For initState() and dispose() to call add them in the respective PageView widgets

Upvotes: 1

Related Questions