ditwin_alert 0.0.1
ditwin_alert: ^0.0.1 copied to clipboard
A clean, customizable alert notification system for Flutter applications
Ditwin Alerts #
A Flutter package for displaying beautiful, customizable alert overlays.
Features #
- 4 alert types: Success, Error, Warning, Info
- Customizable position (top or bottom)
- Auto-dismiss with customizable duration
- Optional title and action button
- Smooth animations
- Two usage options: Service-based or Direct function
Installation #
Add to your pubspec.yaml:
dependencies:
ditwin_alerts: ^1.0.0
Quick Start #
Initialize the Service (Recommended) #
// In your app initialization
final navigatorKey = GlobalKey<NavigatorState>();
DitwinAlertService().init(navigatorKey);
// In your MaterialApp
MaterialApp(
navigatorKey: navigatorKey,
// ...
)
Show Alerts #
Using the Service (can be called from anywhere)
// Success alert
DitwinAlertService().showSuccess(
'Operation completed successfully!',
title: 'Success', // Optional
);
// Error alert
DitwinAlertService().showError(
'Something went wrong!',
title: 'Error', // Optional
);
// Warning alert
DitwinAlertService().showWarning(
'You have unsaved changes.',
title: 'Warning', // Optional
);
// Info alert
DitwinAlertService().showInfo(
'New version available.',
title: 'Info', // Optional
);
Using the Direct Function (requires context)
showDitwinAlert(
context,
message: 'Operation completed successfully!',
type: AlertType.success,
title: 'Success', // Optional
);
Customization Options #
DitwinAlertService().showSuccess(
'Operation completed successfully!',
title: 'Success', // Optional title
position: Alignment.bottomCenter, // Default is topCenter
duration: Duration(seconds: 5), // Default is 3 seconds
dismissible: true, // Default is true
action: TextButton( // Optional action button
onPressed: () {
// Handle action
},
child: Text('OK'),
),
);
License #
MIT