alert static method

Future<void> alert(
  1. BuildContext context, {
  2. required String title,
  3. required String message,
  4. String actionLabel = 'OK',
  5. Widget? icon,
  6. bool barrierDismissible = true,
  7. XLook look = XLook.standard,
})

Shows an informational alert and completes when it is closed.

Implementation

static Future<void> alert(
  BuildContext context, {
  required String title,
  required String message,
  String actionLabel = 'OK',
  Widget? icon,
  bool barrierDismissible = true,
  XLook look = XLook.standard,
}) {
  final lookPreset = XDialogLook.resolve(look);
  return show<void>(
    context,
    barrierDismissible: barrierDismissible,
    builder: (dialogContext) => AlertDialog(
      icon: icon,
      title: Text(title),
      content: Text(message),
      backgroundColor: lookPreset.backgroundColor,
      elevation: lookPreset.elevation,
      shape: look == XLook.standard ? null : lookPreset.shape,
      actions: [
        TextButton(
          onPressed: () => Navigator.of(dialogContext).pop(),
          child: Text(actionLabel),
        ),
      ],
    ),
  );
}