I am trying to enhance the user experience by preventing accidental app exits. If users press the back button once, they should see a toast message saying, "Press again to exit." If they press the back button again within 2 seconds, the app should exit. If more than 2 seconds pass, the app should reset the back button by pressing the counter.
2
Answers
Define a variable
DateTime? _lastPressedAt;
Create a logic with WillPopScope.
This should work. Let me know if it works for you.
You can a achieve a "double back press for exit" with a Future and a ValueNotifier.