riverpod_toast 0.1.0 copy "riverpod_toast: ^0.1.0" to clipboard
riverpod_toast: ^0.1.0 copied to clipboard

A Riverpod-based toast notification system with overlay support, localization, and adaptive theming.

riverpod_toast #

riverpod_toast is a modular, high-performance toast system built with Riverpod v3 and flutter_styled_toast.

โœจ Features #

  • Overlay-based toast display
  • Riverpod-based logic
  • Localization-ready
  • Adaptive dark/light theming
  • Tap-to-dismiss
  • Throttling and deduplication

โœ… Usage #

  1. Register context:
ref.read(toastControllerProvider.notifier).registerContext(context);
  1. Show toast:
showSuccess(ref, 'toast_success');

Add this to your pubspec.yaml:

dependencies:
  riverpod_toast:
    path: ./packages/riverpod_toast

๐Ÿž riverpod_toast #

Elegant, flexible, and context-free toast notifications for Flutter, powered by Riverpod & Styled Toast.


๐Ÿš€ Tagline #

"RiverpodToast โ€” Show toasts anywhere, powered by Riverpod and overlay magic."


๐ŸŽฏ Overview #

riverpod_toast is a reusable Flutter toast system designed for real-world apps.
Built on top of flutter_styled_toast, Riverpod, and EasyLocalization, it gives you:

  • Queueing
  • Deduplication
  • Adaptive dark mode styling
  • Context-free invocation
  • Global customization
  • Easy integration with localization

โœจ Features #

โœ… Context-free toast โ€” Show toast from anywhere in your app logic, no need for BuildContext
โœ… Toast queue โ€” Handles multiple toast requests without overlap
โœ… Smart deduplication โ€” Prevents spamming the same toast repeatedly
โœ… Dark mode support โ€” Auto-styled based on current theme
โœ… Riverpod-based state โ€” Full control, observability, and testability
โœ… Modular โ€” Easily reusable in any Flutter app
โœ… Custom animations & positioning โ€” Built on top of flutter_styled_toast
โœ… EasyLocalization integration โ€” Optional auto-localized messages
โœ… No external dependencies like fluttertoast


โš–๏ธ Comparison #

Feature riverpod_toast ScaffoldMessenger fluttertoast
No context needed โœ… โŒ โœ…
Works in overlays/dialogs โœ… โŒ โœ…
Queueing โœ… โŒ โŒ
Deduplication โœ… โŒ โŒ
EasyLocalization support โœ… โŒ โŒ
Riverpod integration โœ… โŒ โŒ
Custom animation & styling โœ… โš ๏ธ โš ๏ธ
Platform-native support โŒ โœ… โœ…
Built-in Material Design feel โš ๏ธ โœ… โŒ

๐Ÿงฉ Installation #

flutter pub add riverpod_toast

Make sure to also have: (see example/pubspec.yaml)

dependencies:
  flutter_riverpod: ^3.0.0
  riverpod_annotation: ^3.0.0
  easy_localization: ^3.0.8
  flutter_styled_toast: ^2.2.1
  build_runner:
  riverpod_generator:

๐Ÿ› ๏ธ Setup #

1. Wrap your app with ProviderScope and EasyLocalization

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await EasyLocalization.ensureInitialized();

  runApp(
    ProviderScope(
      child: EasyLocalization(
        supportedLocales: const [Locale('en')],
        path: 'assets/translations',
        fallbackLocale: const Locale('en'),
        child: const MyApp(),
      ),
    ),
  );
}

2. Register context after StyledToast is mounted

class MyApp extends ConsumerWidget {
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return StyledToast(
      locale: context.locale,
      child: MaterialApp(
        home: ToastContextRegistrar(
          child: const HomePage(),
        ),
      ),
    );
  }
}

class ToastContextRegistrar extends ConsumerStatefulWidget {
  final Widget child;
  const ToastContextRegistrar({required this.child});

  @override
  ConsumerState<ToastContextRegistrar> createState() => _ToastContextRegistrarState();
}

class _ToastContextRegistrarState extends ConsumerState<ToastContextRegistrar> {
  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      ref.read(toastControllerProvider.notifier).registerContext(context);
    });
  }

  @override
  Widget build(BuildContext context) => widget.child;
}

โœ… Usage #

In any widget or service:

showSuccess(ref, 'Operation successful');
showError(ref, 'Something went wrong!');
showWarning(ref, 'Be careful!');
showInfo(ref, 'This is an info message');

You donโ€™t need to pass context โ€” itโ€™s already registered via Riverpod.


๐ŸŒ“ Dark Mode & Styling #

Toasts adapt automatically based on the theme. You can customize animations, padding, colors, border radius, etc., by editing ToastController._buildToastWidget(...).


๐ŸŒ Localization #

If you're using EasyLocalization, toast messages can be translated automatically:

showSuccess(ref, 'msg_operation_successful'.tr());

You can also configure whether a message should be treated as localized using the localized flag in show().


๐Ÿงช Testing & Debugging #

You can inspect the internal queue using:

final queue = ref.watch(toastControllerProvider);

Logs are printed during registration, deduplication, and toast display.


๐Ÿ“ฆ Folder Structure #

  • lib/riverpod_toast.dart: main export
  • src/toast_controller.dart: Riverpod notifier with queue/dedupe logic
  • src/toast_type.dart: enum for toast types
  • src/toast_helpers.dart: exposed functions like showSuccess()

๐Ÿ”ฎ Coming Soon #

โœ… ToastScope widget โ€” auto-registers context with no boilerplate โœ… Actionable toasts โ€” support for actions like UNDO, RETRY, etc. โœ… Global fallback to ScaffoldMessenger if overlay not available โœ… Adaptive styling hooks for Material 3 & platform UI โœ… Configuration builder for themes, durations, animation styles โœ… Optional ToastTheme override per toast โœ… Support for persistent toasts with dismiss buttons


๐Ÿค Contribution #

Feel free to open issues or submit PRs. Weโ€™re keeping this package modular, Riverpod-native, and customizable.


๐Ÿ“„ License #

MIT โ€” use freely for personal or commercial projects.


Made with โค๏ธ by [sumitsharansatsangi].

0
likes
150
points
139
downloads

Publisher

verified publisherkumpali.com

Weekly Downloads

A Riverpod-based toast notification system with overlay support, localization, and adaptive theming.

Homepage
Repository (GitHub)
View/report issues

Topics

#toast #snackbar #riverpod #riverpod-toast #notification

Documentation

API reference

License

MIT (license)

Dependencies

easy_localization, flutter, flutter_riverpod, flutter_styled_toast, riverpod_annotation

More

Packages that depend on riverpod_toast