showConfirmationKDialog function
Future<bool>
showConfirmationKDialog(
- BuildContext context, {
- String? title,
- String? message,
- String? acceptText,
- String? cancelText,
Implementation
Future<bool> showConfirmationKDialog(
BuildContext context, {
String? title,
String? message,
String? acceptText,
String? cancelText,
}) async {
message ??= strings.confirmDialogText;
acceptText ??= strings.confirmButtonText;
cancelText ??= strings.cancelButtonText;
final result = await showDialog<bool>(
context: context,
barrierDismissible: false,
builder: (context) {
return PopScope(
canPop: false,
child: AlertDialog(
title: title != null ? Text(title) : null,
content: SingleChildScrollView(
child: Text(message!),
),
actionsPadding: title == null
? const EdgeInsets.only(right: 24, bottom: 8)
: null,
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: Text(
cancelText!,
style: const TextStyle(fontWeight: FontWeight.bold),
),
),
TextButton(
onPressed: () => Navigator.of(context).pop(true),
child: Text(
acceptText!,
style: const TextStyle(fontWeight: FontWeight.bold),
),
),
],
),
);
},
);
return result ?? false;
}