Want to close app on device back button in flutter? What you need to do is first clear all path before going to login() screen.
Try this example:
1 2 3 4 5 6 7 8 | onPressed:(){ clearSession(); //Navigator.popUntil(context, ModalRoute.withName('/')); Navigator.pop(context,true);// It worked for me instead of above line Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => Login()),); }, |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.