toastio
A lightweight, animated Glassmorphism toast package for Flutter with global and context-based APIs.
Features
- Success, error, warning and info toast types
- Global toast without passing
BuildContext - Context-based API
- Glassmorphism UI with blur
- Smooth fade, slide and scale animations
- Close button
- Auto dismiss
- Custom background and text colors
- Custom icon and leading widget
- Top, center and bottom positions
- No GetX or other third-party dependencies
📸 Screenshots
Installation
Add the package to your pubspec.yaml:
dependencies:
toastio: ^1.0.3
Then run:
flutter pub get
Global Setup
Create a navigator key:
final navigatorKey = GlobalKey<NavigatorState>();
Initialize the package:
void main() {
WidgetsFlutterBinding.ensureInitialized();
Toastio.initialize(navigatorKey);
runApp(
MaterialApp(
navigatorKey: navigatorKey,
home: const HomePage(),
),
);
}
Now you can call a toast from anywhere:
Toastio.success('Profile updated');
Toastio.error(
'Something went wrong',
title: 'Error',
);
Toastio.warning('Please check your input');
Toastio.info('New message received');
Context API
If you already have a BuildContext:
Toastio.show(
context,
'Saved successfully',
type: ToastType.success,
);
Customization
Customize the toast appearance, duration, position, colors, and close button:
Toastio.showGlobal(
'Custom toast',
type: ToastType.info,
title: 'Information',
duration: const Duration(seconds: 4),
bgColor: Colors.black,
textColor: Colors.white,
position: ToastPosition.bottom,
showCloseButton: true,
);
Custom Icon
Toastio.showGlobal(
'Upload complete',
icon: const Icon(Icons.cloud_done),
);
Custom Leading Widget
Toastio.showGlobal(
'New message',
leading: const CircleAvatar(
radius: 12,
child: Icon(Icons.person, size: 14),
),
);
Dismiss Manually
You can dismiss the currently visible toast manually:
Toastio.dismiss();
Toast Positions
Toast messages can be displayed at different positions:
Toastio.showGlobal(
'Top toast',
position: ToastPosition.top,
);
Available positions:
ToastPosition.topToastPosition.centerToastPosition.bottom
Duration
Set a custom duration for the toast:
Toastio.showGlobal(
'This toast stays longer',
duration: const Duration(seconds: 4),
);
Example
Check the example/ directory for a complete Flutter example demonstrating the available toast types and customization options.
Contributing
Contributions are welcome! ❤️
If you have an idea, bug fix, improvement, or new feature, feel free to contribute.
How to Contribute
- Fork the repository
- Create a new branch
git checkout -b feature/my-feature
- Make your changes
- Test your changes
flutter test
- Commit your changes
git commit -m "Add my feature"
- Push your branch
git push origin feature/my-feature
- Open a Pull Request
Please keep contributions clean, focused, and consistent with the existing code style.
Issues & Suggestions
Found a bug or have an idea?
Feel free to open an issue and share your feedback. Every suggestion and contribution is appreciated.
License
MIT License.