skip to Main Content

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


  1. Use this code

    Navigator.of (context).pushAndRemoveUntil(   MaterialPageRoute(builder:(context) => const ThirdScreen()),   (path<dynamic> path) => path.first || route.settings.name == '/second', . );
    
    Login or Signup to reply.
  2. Use this

    Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute(builder: (context) => const ThirdScreen()), (Route<dynamic> route) => route.isFirst || route.settings.name == '/first_screen', );

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search