deleteConfirmation function
Delete confirmation Shows a dialog and returns a bool
Implementation
Future<bool?> deleteConfirmation(BuildContext context) async {
TextStyle text = const TextStyle(
fontSize: 23,
color: Colors.white,
);
return (await showDialog<bool>(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return SimpleDialog(
title: const Text("Confirm delete?"),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20))),
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Card(
color: Colors.blueGrey,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20))),
child: TextButton(
child: Text(
"Cancel",
style: text,
),
onPressed: () {
SoundPlayer.i.play(Sounds.click);
Navigator.of(context).pop(false);
}),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Card(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20))),
color: Colors.red[800],
child: TextButton(
child: Text(
"Delete",
style: text,
),
onPressed: () {
SoundPlayer.i.play(Sounds.trash);
Navigator.of(context).pop(true);
}),
),
)
],
);
},
));
}