Flutter Navigator.pushReplacementNamed show back button at the page

Issue

I’m using Navigator.pushReplacementNamed in flutter app to navigate from loginpage to homepage working well, but in my homepage show back arrow button at the appBar and it returns to loginpage when pressing it. What should I do? I tried put leading: Text(''), but when pressing physical back button it still goes back to loginpage.

I have a logout button and I want user to logout only by this button, not from back button

*this is my first question here, sorry for my poor English or any mistakes

Solution

You should use this instead:

.pushNamedAndRemoveUntil(/* Your Route */, (Route<dynamic> route) => false)

Answered By – Ulaş Kasım

Answer Checked By – Pedro (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *