showDestructiveConfirmation static method

Future<bool> showDestructiveConfirmation({
  1. required String title,
  2. String? message,
  3. required String destructiveTitle,
  4. VoidCallback? onDestroy,
})

Shows a destructive confirmation alert.

Implementation

static Future<bool> showDestructiveConfirmation({
  required String title,
  String? message,
  required String destructiveTitle,
  VoidCallback? onDestroy,
}) async {
  final result = await show(
    title: title,
    message: message,
    actions: [
      CNAlertAction(title: 'Cancel', style: CNAlertActionStyle.cancel),
      CNAlertAction(
        title: destructiveTitle,
        style: CNAlertActionStyle.destructive,
        onPressed: onDestroy,
      ),
    ],
  );

  return result == 1; // Returns true if destructive action was tapped
}