in my app I have Sixth screen each screen have one button .when you click the button you navigate to next screen. I want to try when you hit screen button you navigate to third screen and remove fourth,fifth & sixth screen from the navigation stack and after in my navigation stack on three screen first,second & third
I use this code
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const thirdScreen()),(Route<dynamic> route) => route.isFirst
);
2
Answers
Use this code
Use this
Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute(builder: (context) => const ThirdScreen()), (Route<dynamic> route) => route.isFirst || route.settings.name == '/first_screen', );