so I have an app which, let's say, consist of just a home screen, a profile screen and a basket screen. From the main/home screen, I can get to both other screens. Actually, I can access all of those three screens via a sidebar. If I start the app in the debug mode I can navigate as follows:
HomeScreen -> ProfileScreen -> HomeScreen (over sidebar) -> Profile Screen.
All of those are done via Navigator.pushNamed(). This means, the _history stack of the Navigator has:
- HomeScreen
- ProfileScreen
- HomeScreen
- Profile Screen
Which is kinda dumb and it uses RAM without the need to do so. I could fix that problem by just using popUntil() every time I get to the HomeScreen so that I have a fresh history but that wouldn't help if I do something like:
HomeScreen -> ProfileScreen -> BasketScreen (over sidebar) -> Profile Screen (over sidebar) -> BasketScreen (over sidebar).
How do I get rid of the RIGHT screens from the history, ideally without making my own Navigator? Is it possible at all? I mean, ideally, the history of the Navigator after the last example should look like this:
- HomeScreen
- Profile Screen
- BasketScreen
(meaning if the BasketScreen is called, it removed all previous BasketScreens from the history, etc.)
Or is it just my mistake to allow such cyclic calls in the first place? Though I doubt I'm the only one to use Sidebars like that.