I am using go_router and I want to exit my app from a subroute when the user presses the back button. for example, I have routes ‘/’, ‘/a’, ‘/b’, ‘/a/1’. now I from the ‘/a/1’ route I want to exit the app when the user presses the back button(based on some condition). please help me
2
Answers
just wrap the
Scaffold
withWillPopScope
Wrap your Page’s Scaffhold with WillPopScope Widget and add this invokeMethod to onWillPop.