Skip to main content

Dialog

The C2CDialog class provides a convenient way to display customizable dialog boxes in Flutter applications. It includes methods for showing both confirmation and alert dialogs with various customization options.

Example Usage

Confirmation Dialog

C2CDialog.showConfirm(
context: context,
title: Text('Confirm'),
content: Text('Are you sure you want to proceed?'),
submitText: 'Yes',
cancelText: 'No',
onSubmit: () => print('Confirmed'),
onCancel: () => print('Cancelled')
);

Alert Dialog

C2CDialog.showAlert(
context: context,
title: Text('Alert'),
content: Text('This is an important alert.'),
submitText: 'Ok',
onSubmit: () => print('Alert acknowledged')
);

Properties

PropertyDescriptionType
contextThe BuildContext where the dialog is to be shown.BuildContext
titleThe title of the dialog. Can be any widget, typically a Text widget.dynamic
contentThe content of the dialog, usually a Text or Widget.dynamic
submitTextThe text for the submit button.String
cancelTextThe text for the cancel button (only for confirm dialog).String
onSubmitCallback function executed when the submit button is pressed.VoidCallback?
onCancelCallback function executed when the cancel button is pressed.VoidCallback?
cancelTypeThe style of the cancel button (only for confirm dialog).DialogActionType
submitTypeThe style of the submit button.DialogActionType
actionsCustom actions or buttons to show in the dialog.List<Widget>?
backgroundColorThe background color of the dialog.Color?
titleTextStyleThe text style for the title.TextStyle?
contentTextStyleThe text style for the content.TextStyle?
titlePaddingThe padding around the title widget.EdgeInsets?
contentPaddingThe padding around the content widget.EdgeInsets?
maxWidthThe maximum width of the dialog.double?
dividerColorThe color of the divider between content and actions.Color?
dividerThicknessThe thickness of the divider.double?
scrollableWhether the content is scrollable.bool
useRootNavigatorWhether to use the root navigator for displaying the dialog.bool
barrierDismissibleIf true, dialog will dismiss when the barrier is clicked.bool
barrierLabelSemantic label for the dialog's barrier (for accessibility purposes).String?
barrierColorThe color of the modal barrier that darkens the rest of the screen.Color?
transitionDurationDuration of the transition animation for the dialog appearance.Duration
transitionBuilderA builder for the dialog's transition animation.RouteTransitionsBuilder?
routeSettingsAdditional settings for the route used to show the dialog.RouteSettings?
anchorPointThe anchor point where the dialog should be centered.Offset?