showSubZeroDialog<T> function
Future<T?>
showSubZeroDialog<T>({
- required BuildContext context,
- required String title,
- String? subtitle,
- String? body,
- Widget? content,
- SubZeroDialogActions? actions,
- SubZeroDialogActionLayout actionLayout = SubZeroDialogActionLayout.sideBySide,
- Widget? customActions,
- bool barrierDismissible = true,
- double? maxWidth,
- EdgeInsets? contentPadding,
Shows a SubZero-styled modal dialog.
This function displays a modal dialog that interrupts the user's workflow to convey critical information, request a decision, or initiate a focused task.
Returns a Future that completes when the dialog is dismissed.
Example usage:
// Simple dialog with two buttons
showSubZeroDialog(
context: context,
title: 'Confirm Action',
body: 'Are you sure you want to proceed?',
actions: SubZeroDialogActions(
primaryLabel: 'Confirm',
onPrimary: () => Navigator.of(context).pop(true),
secondaryLabel: 'Cancel',
onSecondary: () => Navigator.of(context).pop(false),
),
);
// Dialog with flushed button
showSubZeroDialog(
context: context,
title: 'Success',
body: 'Your changes have been saved.',
actionLayout: SubZeroDialogActionLayout.flushed,
actions: SubZeroDialogActions(
primaryLabel: 'Continue',
onPrimary: () => Navigator.of(context).pop(),
primaryTrailingIcon: Icons.add,
),
);
Implementation
Future<T?> showSubZeroDialog<T>({
required BuildContext context,
required String title,
String? subtitle,
String? body,
Widget? content,
SubZeroDialogActions? actions,
SubZeroDialogActionLayout actionLayout = SubZeroDialogActionLayout.sideBySide,
Widget? customActions,
bool barrierDismissible = true,
double? maxWidth,
EdgeInsets? contentPadding,
}) {
return showGeneralDialog<T>(
context: context,
barrierDismissible: barrierDismissible,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
barrierColor: Colors.black.withValues(alpha: 0.6),
transitionDuration: const Duration(milliseconds: 200),
pageBuilder: (context, animation, secondaryAnimation) {
return SubZeroDialog(
title: title,
subtitle: subtitle,
body: body,
content: content,
actions: actions,
actionLayout: actionLayout,
customActions: customActions,
maxWidth: maxWidth,
contentPadding: contentPadding,
);
},
transitionBuilder: (context, animation, secondaryAnimation, child) {
return ScaleTransition(
scale: CurvedAnimation(
parent: animation,
curve: Curves.easeOutCubic,
),
child: FadeTransition(
opacity: animation,
child: child,
),
);
},
);
}