Home > Enterprise >  Navigator.push has access to previous page - flutter
Navigator.push has access to previous page - flutter

Time:11-09

in my app I have implemented various pages that open in different conditions, to open the pages I always used

 Navigator.push(context,
                      MaterialPageRoute(builder: (context) => MyPage())
                  );

I always did my tests on iOS simulators but now I tried in android and I discovered that if I use the go back button of the phone the previous page shows up, is there a way to close the page?

CodePudding user response:

To not let user go back to previous screen I would use:

Navigator.pushNamedAndRemoveUntil(
      context, routeID, (route) => false);

Where routeID is the route you want to push to.

  • Related