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
| Property | Description | Type |
|---|---|---|
context | The BuildContext where the dialog is to be shown. | BuildContext |
title | The title of the dialog. Can be any widget, typically a Text widget. | dynamic |
content | The content of the dialog, usually a Text or Widget. | dynamic |
submitText | The text for the submit button. | String |
cancelText | The text for the cancel button (only for confirm dialog). | String |
onSubmit | Callback function executed when the submit button is pressed. | VoidCallback? |
onCancel | Callback function executed when the cancel button is pressed. | VoidCallback? |
cancelType | The style of the cancel button (only for confirm dialog). | DialogActionType |
submitType | The style of the submit button. | DialogActionType |
actions | Custom actions or buttons to show in the dialog. | List<Widget>? |
backgroundColor | The background color of the dialog. | Color? |
titleTextStyle | The text style for the title. | TextStyle? |
contentTextStyle | The text style for the content. | TextStyle? |
titlePadding | The padding around the title widget. | EdgeInsets? |
contentPadding | The padding around the content widget. | EdgeInsets? |
maxWidth | The maximum width of the dialog. | double? |
dividerColor | The color of the divider between content and actions. | Color? |
dividerThickness | The thickness of the divider. | double? |
scrollable | Whether the content is scrollable. | bool |
useRootNavigator | Whether to use the root navigator for displaying the dialog. | bool |
barrierDismissible | If true, dialog will dismiss when the barrier is clicked. | bool |
barrierLabel | Semantic label for the dialog's barrier (for accessibility purposes). | String? |
barrierColor | The color of the modal barrier that darkens the rest of the screen. | Color? |
transitionDuration | Duration of the transition animation for the dialog appearance. | Duration |
transitionBuilder | A builder for the dialog's transition animation. | RouteTransitionsBuilder? |
routeSettings | Additional settings for the route used to show the dialog. | RouteSettings? |
anchorPoint | The anchor point where the dialog should be centered. | Offset? |