Want to use confirmDismiss in Dismissible in flutter? In the confirmDismiss attribute you can return an AlertDialog() (or whatever type of dialog you prefer) and then list the possible outcomes (e.g., delete and cancel) in buttons and return either true (delete) or false (cancel) which then determines if the item has to be removed or needs to stay in the list.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | confirmDismiss: (DismissDirection direction) async { final bool res = await showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: const Text("Confirm"), content: const Text("Are you sure you wish to delete this item?"), actions: <Widget>[ FlatButton( onPressed: () => Navigator.of(context).pop(true), child: const Text("DELETE") ), FlatButton( onPressed: () => Navigator.of(context).pop(false), child: const Text("CANCEL"), ), ], ); }, ); }, |
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.