deleteConfirmation function
Future<bool>
deleteConfirmation(
- BuildContext context, {
- bool enableSound = true,
- String? message,
- Widget? denyMessage,
- Widget? confirmMessage,
- Color? denyButtonColor,
- Color? confirmButtonColor,
- AsyncCallback? onPressedDeny,
- AsyncCallback? onPressedConfirm,
Delete confirmation dialog Shows a dialog with cancel and delete buttons and returns a confirmation bool
Implementation
Future<bool> deleteConfirmation(
BuildContext context, {
bool enableSound = true,
String? message,
Widget? denyMessage,
Widget? confirmMessage,
Color? denyButtonColor,
Color? confirmButtonColor,
AsyncCallback? onPressedDeny,
AsyncCallback? onPressedConfirm,
}) async {
return await showDialog<bool>(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return SimpleDialog(
title: Text(message ?? "Confirm delete?"),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20))),
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Card(
color: denyButtonColor ?? Colors.blueGrey,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20))),
child: denyMessage ??
TextButton(
child: Text(
"Cancel",
style: text,
),
onPressed: onPressedDeny ??
() {
if (enableSound) SoundPlayer.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: confirmButtonColor ?? Colors.red[800],
child: TextButton(
child: confirmMessage ??
Text(
"Delete",
style: text,
),
onPressed: onPressedConfirm ??
() {
if (enableSound) SoundPlayer.play(Sounds.deleted);
Navigator.of(context).pop(true);
}),
),
)
],
);
},
) ??
false;
}