confirm static method

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

Implementation

static Future<bool> confirm(
  BuildContext context, {
  required String title,
  required String message,
  String cancelLabel = 'Cancel',
  String confirmLabel = 'Confirm',
  bool destructive = false,
}) async {
  final result = await show<bool>(
    context,
    title: title,
    content: Text(
      message,
      style: context.typography.paragraph.copyWith(
        color: context.colors.textSecondary,
      ),
    ),
    actions: [
      KiteButton(
        label: cancelLabel,
        variant: KiteButtonVariant.ghost,
        onPressed: () => Navigator.of(context).pop(false),
      ),
      KiteButton(
        label: confirmLabel,
        variant: destructive
            ? KiteButtonVariant.danger
            : KiteButtonVariant.filled,
        onPressed: () => Navigator.of(context).pop(true),
      ),
    ],
  );
  return result ?? false;
}