Created
May 22, 2021 23:40
-
-
Save jtmuller5/ccba4fa1517f5914f5dd346e8f9b0405 to your computer and use it in GitHub Desktop.
Ask the user to approve or cancel an action in a pop-up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Future<bool> askConfirmation({ | |
| required BuildContext context, | |
| required String title, | |
| String yes = 'Continue', | |
| String no = 'Cancel', | |
| }) async { | |
| return await showDialog( | |
| context: context, | |
| builder: (context) { | |
| return AlertDialog( | |
| title: Center(child: Text(title)), | |
| actions: [ | |
| TextButton( | |
| child: Text(no), | |
| onPressed: () { | |
| appRouter.pop(false); | |
| }, | |
| ), | |
| TextButton( | |
| child: Text( | |
| yes, | |
| style: TextStyle(color: Colors.red), | |
| ), | |
| onPressed: () { | |
| appRouter.pop(true); | |
| }, | |
| ) | |
| ], | |
| ); | |
| }, | |
| ) ?? | |
| false; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment