- Customizable styles including text, background color, leading icons and more
- Responsive layout design, uses Media Queries to adapt on various screen sizes
- Pre-defined methods for various message types with default styles and icons
- Being an overlay, it doesn't disturb the widget tree or get affected by context change
![](https://private-user-images.githubusercontent.com/117360930/327022641-89ada1ca-4f5d-4a54-9139-84c0d752f831.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk5Nzg0ODksIm5iZiI6MTcxOTk3ODE4OSwicGF0aCI6Ii8xMTczNjA5MzAvMzI3MDIyNjQxLTg5YWRhMWNhLTRmNWQtNGE1NC05MTM5LTg0YzBkNzUyZjgzMS5naWY_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzAzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcwM1QwMzQzMDlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lODFkZTViY2VkZmI3ZGFkNDkzNDEwYTE4NzRhZGYxODBiNWVlOTNjNjA0MTMzZDMzMDIyMTJjOTNhZTkwZTAxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.q-aDOBtgft2sNAJbbFB-CDEZ0qY0cH1K-VDzmLpVZKQ)
Add top_snackbar
to your pubspec.yaml
file:
dependencies:
top_snackbar: ^0.0.6 # Use the latest version
import 'package:flutter/material.dart';
import 'package:top_snackbar/top_snackbar.dart';
To show a custom top snackbar message, use the CustomTopSnackbar.show
method:
CustomTopSnackbar.show(
context,
'Your message here',
// Customize more additional properties as required (optional)
leadingIcon: Icons.copy,
backgroundColor: Colors.blue,
);
The library provides pre-defined methods for different message types with default styles and icons:
- Info: Display an informational message.
CustomTopSnackbar.showInfo(context, 'Info message');
- Success: Display a success message.
CustomTopSnackbar.showSuccess(context, 'Success message');
- Error: Display an error message.
CustomTopSnackbar.showError(context, 'Error message');
- Warning: Display a warning message.
CustomTopSnackbar.showWarning(context, 'Warning message');