apptomate_custom_alert_dialog 0.0.1
apptomate_custom_alert_dialog: ^0.0.1 copied to clipboard
A highly customizable and reusable AlertDialog widget for Flutter applications, designed to provide consistent and flexible dialogs with support for dark mode, custom icons, scrollable content, and more.
CustomAlertDialog for Flutter #
A highly customizable and reusable AlertDialog widget for Flutter applications, designed to provide consistent and flexible dialogs with support for dark mode, custom icons, scrollable content, and more.
📌 Key Features #
✅ Fully Customizable – Control colors, text styles, padding, and shapes.
✅ Dark Mode Support – Automatically adapts to the app's theme.
✅ Icon Support – Add an optional icon with customizable color and size.
✅ Flexible Content – Supports both simple text and custom widgets.
✅ Scrollable Content – Handles long messages with a scrollable view.
✅ Custom Buttons – Configure confirm/cancel buttons with different styles.
✅ Divider Option – Add a divider between the title and content.
✅ Pre-Built Examples – Includes common dialog types (confirmation, error, info, etc.).
✅ Responsive Design – Works seamlessly across all screen sizes.
📥 Installation #
Add the dependency to your pubspec.yaml:
dependencies:
apptomate_custom_alert_dialog: ^0.0.1
🚀 Basic Usage #
1. Simple Confirmation Dialog #
showDialog(
context: context,
builder: (context) => CustomAlertDialog(
title: "Confirm Action",
content: "Are you sure you want to delete this item?",
confirmText: "Delete",
cancelText: "Cancel",
onConfirm: () {
// Handle delete action
},
icon: Icons.warning,
iconColor: Colors.orange,
),
);
2. Information Dialog #
showDialog(
context: context,
builder: (context) => CustomAlertDialog(
title: "Success",
content: "Your changes have been saved successfully!",
confirmText: "OK",
icon: Icons.check_circle,
iconColor: Colors.green,
),
);
3. Error Dialog #
showDialog(
context: context,
builder: (context) => CustomAlertDialog(
title: "Error",
content: "Failed to load data. Please try again.",
confirmText: "Retry",
cancelText: "Cancel",
confirmButtonColor: Colors.red,
icon: Icons.error,
backgroundColor: Colors.red[50],
),
);
4. Custom Content Dialog #
showDialog(
context: context,
builder: (context) => CustomAlertDialog(
title: "Feedback",
customContent: Column(
children: [
TextField(decoration: InputDecoration(labelText: "Name")),
TextField(decoration: InputDecoration(labelText: "Email")),
CheckboxListTile(
title: Text("Subscribe to newsletter"),
value: false,
onChanged: (val) {},
),
],
),
confirmText: "Submit",
cancelText: "Close",
),
);
⚙️ Customization Options #
| Property | Type | Description | Default |
|---|---|---|---|
title |
String |
Dialog title (required) | - |
content |
String |
Main dialog message | - |
confirmText |
String? |
Text for confirm button | null |
cancelText |
String? |
Text for cancel button | null |
onConfirm |
VoidCallback? |
Action on confirm button press | null |
onCancel |
VoidCallback? |
Action on cancel button press | null |
confirmButtonColor |
Color? |
Background color for confirm button | Theme primary color |
cancelButtonColor |
Color? |
Text color for cancel button | Colors.red |
backgroundColor |
Color? |
Dialog background color | Auto (light/dark theme) |
titleTextStyle |
TextStyle? |
Custom style for title | Bold, size 18 |
contentTextStyle |
TextStyle? |
Custom style for content | Size 16 |
icon |
IconData? |
Optional leading icon | null |
iconColor |
Color? |
Icon color | Theme primary color |
iconSize |
double? |
Icon size | 28 |
scrollable |
bool |
Enable scrolling for long content | false |
contentPadding |
EdgeInsetsGeometry? |
Padding around content | EdgeInsets.fromLTRB(24, 0, 24, 24) |
shape |
ShapeBorder? |
Custom dialog shape (e.g., rounded corners) | Default dialog shape |
customContent |
Widget? |
Replace default content with a custom widget | null |
showDivider |
bool |
Show a divider below title | false |
dividerColor |
Color? |
Divider color | Theme divider color |
dividerThickness |
double? |
Divider thickness | 1.0 |