show<T> static method

Future<T?> show<T>(
  1. BuildContext context, {
  2. required String title,
  3. required WidgetBuilder content,
  4. String? subtitle,
  5. Widget? headerLeading,
  6. bool showCloseButton = true,
  7. double maxWidth = 480,
  8. bool scrollableBody = true,
  9. FutureOr<T?> onConfirm()?,
  10. VoidCallback? onCancel,
  11. String confirmLabel = 'Conferma',
  12. String cancelLabel = 'Annulla',
  13. bool barrierDismissible = true,
})

Apre un CLDialog inline, senza sottoclasse. Ritorna il risultato di onConfirm (o null se annullato/chiuso).

final ok = await CLDialog.show<bool>(
  context,
  title: 'Gestisci contatti',
  headerLeading: IconBadge(icon: Icons.contacts, color: theme.primary),
  maxWidth: 520,
  content: (ctx) => _contactsForm,
  confirmLabel: 'Salva',
  onConfirm: () => vm.save(),
);

Implementation

static Future<T?> show<T>(
  BuildContext context, {
  required String title,
  required WidgetBuilder content,
  String? subtitle,
  Widget? headerLeading,
  bool showCloseButton = true,
  double maxWidth = 480,
  bool scrollableBody = true,
  FutureOr<T?> Function()? onConfirm,
  VoidCallback? onCancel,
  String confirmLabel = 'Conferma',
  String cancelLabel = 'Annulla',
  bool barrierDismissible = true,
}) {
  return showDialog<T>(
    context: context,
    barrierDismissible: barrierDismissible,
    builder: (_) => _CLBuilderDialog<T>(
      title: title,
      subtitle: subtitle,
      headerLeading: headerLeading,
      showCloseButton: showCloseButton,
      maxWidth: maxWidth,
      scrollableBody: scrollableBody,
      onConfirm: onConfirm,
      onCancel: onCancel,
      confirmLabel: confirmLabel,
      cancelLabel: cancelLabel,
      contentBuilder: content,
    ),
  );
}