A highly customizable, animated notification system for Flutter applications with support for success, error, warning, and info messages.
![Notification Types Preview]
- π― 4 notification types: Success, Error, Warning, Info
- π¨ Fully customizable appearance
- β¨ Smooth animations with slide and fade effects
- π Linear progress indicator (optional)
- π Multiple dismiss actions:
- Swipe to dismiss
- Tap to dismiss
- Auto-dismiss with timer
- π± Safe area aware
- π― Singleton pattern to prevent notification overlap
- π Debug mode support
Add this to your package's pubspec.yaml file:
dependencies:
ace_toast: 0.0.1Then run:
flutter pub getInitialize the notification service in your main app widget:
@override
void initState() {
super.initState();
NotificationService.initialize(context);
}// Success message
NotificationService.showSuccess(
'Successfully saved!',
duration: Duration(seconds: 3),
);
// Error message
NotificationService.showError(
'Something went wrong!',
duration: Duration(seconds: 3),
);
// Warning message
NotificationService.showWarning(
'Low storage space',
duration: Duration(seconds: 3),
);
// Info message
NotificationService.showInfo(
'New update available',
duration: Duration(seconds: 3),
);You can customize the notification appearance using NotificationConfig:
NotificationService.showSuccess(
'Custom styled notification',
config: NotificationConfig(
backgroundColor: Colors.green.shade50,
borderColor: Colors.green.shade200,
textColor: Colors.green.shade900,
iconColor: Colors.green.shade700,
showProgressIndicator: true,
borderRadius: 12.0,
padding: EdgeInsets.all(16),
position: NotificationPosition.top,
animationDuration: Duration(milliseconds: 300),
dismissDirection: DismissDirection.up,
elevation: 2.0,
),
);Set default configuration for all notifications:
NotificationService.setGlobalConfig(
NotificationConfig(
showProgressIndicator: true,
position: NotificationPosition.bottom,
animationDuration: Duration(milliseconds: 400),
),
);Create completely custom notifications using builder:
NotificationService.show(
builder: (context, animation) => YourCustomWidget(
animation: animation,
// ... your custom properties
),
duration: Duration(seconds: 3),
);| Property | Type | Description |
|---|---|---|
| backgroundColor | Color? | Background color of notification |
| borderColor | Color? | Border color of notification |
| textColor | Color? | Text color of notification |
| iconColor | Color? | Icon color of notification |
| showProgressIndicator | bool | Show/hide progress indicator |
| borderRadius | double | Corner radius of notification |
| padding | EdgeInsets | Internal padding of notification |
| position | NotificationPosition | Top or bottom position |
| animationDuration | Duration | Duration of show/hide animations |
| dismissDirection | DismissDirection | Swipe direction to dismiss |
| elevation | double | Shadow elevation of notification |
| icon | IconData? | Custom icon for notification |
| progressIndicatorColor | Color? | Color of progress indicator |
| progressIndicatorHeight | double | Height of progress indicator |
| maxWidth | double? | Maximum width of notification |
| margin | EdgeInsets? | External margin of notification |
NotificationPosition.topNotificationPosition.bottom
DismissDirection.upDismissDirection.downDismissDirection.horizontal
NotificationService.showInfo(
'This is a very long notification message that will wrap to multiple lines automatically while maintaining proper layout and spacing.',
duration: Duration(seconds: 5),
);NotificationService.showSuccess(
'Upload completed!',
config: NotificationConfig(
showProgressIndicator: true,
progressIndicatorColor: Colors.green.shade300,
progressIndicatorHeight: 2,
),
);NotificationService.showWarning(
'Battery low',
config: NotificationConfig(
position: NotificationPosition.bottom,
margin: EdgeInsets.only(bottom: 20),
),
);Enable debug mode to see helpful logs:
NotificationService.debugMode = true;- Initialize the service early in your app lifecycle
- Use appropriate notification types for different scenarios
- Keep messages concise and clear
- Consider user interaction patterns when setting position
- Use consistent styling across your app
- Handle orientation changes appropriately
- Only one notification is shown at a time
- New notifications replace existing ones
- Notifications respect safe areas on all devices
- All customization options are optional with sensible defaults
Feel free to contribute to this project by:
- Reporting bugs
- Suggesting new features
- Creating pull requests
This notification system is open-source and available under the MIT License.