Akhil
Akhil

Reputation: 165

How to exit app with back button instead of just pop

I am building an app(Learning) and on first use the app it show authentication page with login and signup button if user click any one button and fill the fields it will be navigate to homePage.

Navigation :
Authentication Page=>login=>main page

Now the problem is I don't want users to get back to login page if they press back button on home page. Instead I want to exit the app. How can I do it?

Upvotes: 0

Views: 972

Answers (1)

Toni
Toni

Reputation: 5165

When you navigate from login to main page use Navigator method .pushReplacement() instead of .push() and that will replace the login page on Navigator stack. Which means that the main page will be the only one on the stack. Pressing the back button or calling method .pop(), in that case, will close the application.

Upvotes: 1

Related Questions