Skip to main content

toastio 1.0.3 copy "toastio: ^1.0.3" to clipboard
toastio: ^1.0.3 copied to clipboard

A lightweight, animated Glassmorphism toast for Flutter with global and context-based APIs.

pub package pub points likes

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 #

Success Toast Error Toast Warning Toast

Info Toast Top Position Toast Toast with Image

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.top
  • ToastPosition.center
  • ToastPosition.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 #

  1. Fork the repository
  2. Create a new branch
git checkout -b feature/my-feature
  1. Make your changes
  2. Test your changes
flutter test
  1. Commit your changes
git commit -m "Add my feature"
  1. Push your branch
git push origin feature/my-feature
  1. 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.

1
likes
155
points
296
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A lightweight, animated Glassmorphism toast for Flutter with global and context-based APIs.

Repository (GitHub)
View/report issues

Topics

#toast #flutter #notification #snackbar #glassmorphism

License

MIT (license)

Dependencies

flutter

More

Packages that depend on toastio