I have been creating an app with a start(homescreen) that display a list of data extracted from a REST api call. This is triggered to be done when the state of the widget updates - all works fine.
I also have a number of child screens (for instance a settings screen) loaded with:
Navigator.push
I have noticed that if the state changes in my settings screen that the homescreen state is also updated and therefore it calls the REST api again. I have done some testing and this appears to work for any child widget in the Navigator stack where state update appears to be passed back up the widget tree right to the top.
Is this expected behaviour as I thought that state changes went down the widget tree not back up or is this my misunderstanding of the way this works?
It just seems a bit inefficient to me that my REST call in the HomeScreen keeps getting executed and the screen updating every-time a child widget has a state change as it is the base of the Navigator stack and not being used/viewed.
I have put up a simple test project that shows this on Github here.
- Flutter (Channel beta, v0.11.3, on Mac OS X 10.14.1 18B75, locale en-GB)
- Android toolchain - develop for Android devices (Android SDK 28.0.3)
- iOS toolchain - develop for iOS devices (Xcode 10.1)
- Android Studio (version 3.1)
- VS Code (version 1.29.1)