'Pop certain screens and push a screen in flutter
I pushed(with named routes) few screens like so,
BaseScreen >>(pushNamed) ScreenOne >>(pushNamed) ScreenTwo >>(pushNamed) ScreenThree >>(pushNamed) ScreenFour
While I am at ScreenFour what I wanted was that instead of just pushing ScreenFour to the stack, to remove ScreenThree and ScreenTwo from the stack and then have ScreenFour at top of the stack.
so at the end while im at ScreenFour the stack should look like,
BaseScreen >> ScreenOne >> ScreenFour.
How can I achieve this in flutter?
Solution 1:[1]
You can use Navigator.pushAndRemoveUntil() for 2nd and 3rd screen and use normal Navigator.push for 4th screen.
Thus it will be possible.
Learn more about pushAndRemoveUntil here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Aravind Aji |
