showConfirmDialog method

Future<bool> showConfirmDialog({
  1. required String title,
  2. required String message,
  3. String confirmLabel = 'Confirm',
  4. String cancelLabel = 'Cancel',
  5. bool destructive = false,
})

Implementation

Future<bool> showConfirmDialog({
  required String title,
  required String message,
  String confirmLabel = 'Confirm',
  String cancelLabel = 'Cancel',
  bool destructive = false,
}) async {
  final result = await showAppDialog<bool>(
    dialog: AlertDialog(
      title: Text(title),
      content: Text(message),
      actions: [
        TextButton(onPressed: () => pop(false), child: Text(cancelLabel)),
        TextButton(
          onPressed: () => pop(true),
          style:
              destructive
                  ? TextButton.styleFrom(foregroundColor: colorScheme.error)
                  : null,
          child: Text(confirmLabel),
        ),
      ],
    ),
  );
  return result ?? false;
}