1
votes

I'm making a flutter app that downloads its data shown on the different screens from a server, I download each screen's data only when that screen is open by the user, which means I'm not saving the data anywhere on the user's device. when I navigate from a screen to another using navigator.push it takes some time to load which is normal because it loads data from the internet, but when I use navigator.pop to get back to the previous screen that takes a loading time just like the navigator. push, which means it reloads data of the previous screen again from the internet, which makes the navigation between screens, not the smoothest.

Is there a better way to navigate between the screens smoothly when I'm loading data from a server in flutter?

Thank you.

1

1 Answers

0
votes

It is actually how flutter works it doesnt matter if you push to a screen or pop to a screen it will rerun the build method. What you need to do is to put an if statement so when your data is downloaded and isnt null you shouldnt run the download method you have written and it will just build with its previous state.