[go: up one dir, main page]

0% found this document useful (0 votes)
14 views1 page

Alert Dialog

Alert Dialog effects code

Uploaded by

lingdong9910
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views1 page

Alert Dialog

Alert Dialog effects code

Uploaded by

lingdong9910
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

onPressed: () async => showDialog<bool>(

context: context,
builder: (BuildContext context) => AlertDialog(
title: const Text('Delete item'),
content: const Text('Are you sure you want to delete this item?'),
actions: [
ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
child: const Text(
'Delete',
style: TextStyle(color: Colors.white),
),
onPressed: () => Navigator.pop(context, true),
),
TextButton(
child: const Text(
'Cancel',
style: TextStyle(color: Colors.black),
),
onPressed: () => Navigator.pop(context, false),
),
],
),
).then((bool? isDeleted) => isDeleted != null && isDeleted
? ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Item successfully deleted',
textAlign: TextAlign.center,
),
backgroundColor: Colors.red,
),
)
: null)

You might also like