munchtoast 0.1.2 copy "munchtoast: ^0.1.2" to clipboard
munchtoast: ^0.1.2 copied to clipboard

A modern, highly customizable toast/snackbar notification widget for Flutter, perfect for e-commerce applications.

MunchToast ๐Ÿž #

pub package License: MIT

A modern, highly customizable toast/snackbar notification widget for Flutter, perfect for e-commerce applications. MunchToast provides beautiful animations, flexible styling, and a queue system for managing multiple notifications.

MunchToast Demo

MunchToast Position Selector

โœจ Features #

  • ๐ŸŽจ 5 Pre-built Toast Types: Success, Error, Info, Warning, and Custom
  • ๐Ÿ“ Flexible Positioning: Top, Bottom (default), or Center - with interactive example app selector
  • ๐ŸŽญ Smooth Animations: Slide, fade, and scale effects with configurable curves
  • ๐Ÿ›๏ธ E-commerce Ready: Action buttons, icons, and rich text support
  • ๐Ÿ“ฆ Queue System: Automatically manages multiple toasts
  • ๐Ÿ‘† Swipe to Dismiss: Gesture support for easy dismissal
  • ๐ŸŽฏ Zero Dependencies: Built with Flutter SDK only
  • ๐ŸŒ™ Dark Mode Support: Automatically adapts to theme
  • โ™ฟ Accessible: Screen reader support and semantic labels
  • ๐ŸŽจ Highly Customizable: Colors, gradients, borders, padding, and more

๐Ÿ“ฆ Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  munchtoast: ^0.1.0

Then run:

flutter pub get

๐Ÿš€ Quick Start #

Basic Usage #

import 'package:munchtoast/munchtoast.dart';

// Simple success toast (appears at bottom by default)
MunchToast.success(
  context,
  message: 'Order placed successfully!',
);

// Error toast with action button
MunchToast.error(
  context,
  message: 'Payment failed. Please try again.',
  action: MunchToastAction(
    label: 'Retry',
    onPressed: () => _retryPayment(),
  ),
);

// Toast at top position
MunchToast.info(
  context,
  message: 'New products available!',
  position: MunchToastPosition.top,
);

๐Ÿ’ก Tip: Try the example app to interactively test different positions with the built-in selector!

Advanced Usage #

MunchToast.show(
  context,
  message: 'Product added to cart',
  type: MunchToastType.success,
  position: MunchToastPosition.bottom,
  duration: Duration(seconds: 3),
  icon: Icons.shopping_cart,
  action: MunchToastAction(
    label: 'View Cart',
    onPressed: () => Navigator.pushNamed(context, '/cart'),
  ),
  backgroundColor: Colors.green.shade600,
  borderRadius: 12.0,
  elevation: 6.0,
);

๐Ÿ›๏ธ E-commerce Examples #

1. Add to Cart Confirmation #

MunchToast.show(
  context,
  message: '${product.name} added to cart',
  type: MunchToastType.success,
  icon: Icons.check_circle,
  action: MunchToastAction(
    label: '๐Ÿ›’ Cart (${cart.totalItems})',
    onPressed: _openCart,
  ),
);

2. Price Drop Alert #

MunchToast.info(
  context,
  message: '${product.name} is now 30% off!',
  icon: Icons.local_offer,
  duration: Duration(seconds: 5),
  position: MunchToastPosition.top,  // Top position for alerts
);

๐Ÿ’ก Pro Tip: Use top position for time-sensitive alerts like price drops, flash sales, or important notifications that users shouldn't miss.

3. Out of Stock Warning #

MunchToast.warning(
  context,
  message: '${product.name} is out of stock',
  icon: Icons.inventory,
  action: MunchToastAction(
    label: 'Notify me',
    onPressed: _setupBackInStockAlert,
  ),
);

4. Limited Time Offer #

MunchToast.show(
  context,
  message: '๐Ÿ”ฅ Flash sale ends in 2 hours!',
  type: MunchToastType.custom,
  backgroundColor: Colors.deepPurple,
  gradient: LinearGradient(
    colors: [Colors.purple, Colors.pink],
  ),
  icon: Icons.timer,
  duration: Duration(seconds: 8),
);

5. Order Tracking Update #

MunchToast.success(
  context,
  message: 'Your order #1234 has been shipped',
  icon: Icons.local_shipping,
  action: MunchToastAction(
    label: 'Track',
    onPressed: _openTracking,
  ),
);

๐Ÿ“š API Reference #

MunchToast Methods #

MunchToast.show()

Display a toast with full customization options.

Parameters:

  • context (required): BuildContext
  • message (required): String - The message to display
  • type: MunchToastType - Toast type (default: MunchToastType.info)
  • position: MunchToastPosition - Position (default: MunchToastPosition.bottom)
  • duration: Duration - Auto-dismiss duration (default: 3 seconds)
  • action: MunchToastAction? - Optional action button
  • icon: IconData? - Optional leading icon
  • iconColor: Color? - Icon color
  • backgroundColor: Color? - Background color (overrides type defaults)
  • gradient: Gradient? - Gradient background (overrides backgroundColor)
  • borderRadius: double - Border radius (default: 12.0)
  • elevation: double - Shadow elevation (default: 6.0)
  • onDismiss: VoidCallback? - Callback when toast is dismissed
  • persistent: bool - Require manual dismiss (default: false)
  • textStyle: TextStyle? - Custom text style
  • padding: EdgeInsets? - Custom padding
  • margin: EdgeInsets? - Custom margin
  • offset: Offset? - Custom position offset
  • animationCurve: Curve - Animation curve (default: Curves.easeOut)
  • enableSwipeToDismiss: bool - Enable swipe gesture (default: true)
  • customWidget: Widget? - Custom widget instead of default content

MunchToast.success()

Shorthand for success toasts.

MunchToast.error()

Shorthand for error toasts.

MunchToast.info()

Shorthand for info toasts.

MunchToast.warning()

Shorthand for warning toasts.

MunchToast.dismissAll()

Dismiss all active toasts for a context.

MunchToastType Enum #

  • success - Green theme for successful operations
  • error - Red theme for errors/warnings
  • info - Blue theme for informational messages
  • warning - Orange theme for cautionary messages
  • custom - Full control over colors and styling

MunchToastPosition Enum #

  • top - Top of the screen (great for alerts and important notifications)
  • bottom - Bottom of the screen (default, ideal for confirmations and actions)
  • center - Center of the screen (perfect for modal-style notifications)

Best Practices:

  • Use top for alerts, warnings, and time-sensitive information
  • Use bottom for confirmations, success messages, and action feedback
  • Use center for critical messages that require immediate attention

MunchToastAction Class #

MunchToastAction(
  label: 'Action',           // Required: Button label
  onPressed: () {},          // Required: Callback function
  textStyle: TextStyle(),    // Optional: Custom text style
  backgroundColor: Color(),  // Optional: Button background
  foregroundColor: Color(),  // Optional: Button text color
)

๐ŸŽจ Customization Guide #

Position Selection #

Choose where toasts appear on screen:

// Top position - slides down from top
MunchToast.success(
  context,
  message: 'Notification from top',
  position: MunchToastPosition.top,
);

// Bottom position - slides up from bottom (default)
MunchToast.success(
  context,
  message: 'Notification from bottom',
  position: MunchToastPosition.bottom,
);

// Center position - appears in center
MunchToast.info(
  context,
  message: 'Centered notification',
  position: MunchToastPosition.center,
);

Tip: Use top position for important alerts that shouldn't be missed, bottom for confirmations and actions.

Custom Colors #

MunchToast.show(
  context,
  message: 'Custom colored toast',
  backgroundColor: Colors.purple.shade700,
  iconColor: Colors.white,
);

Gradient Backgrounds #

MunchToast.show(
  context,
  message: 'Gradient toast',
  gradient: LinearGradient(
    colors: [Colors.blue, Colors.purple],
  ),
);

Custom Borders #

MunchToast.show(
  context,
  message: 'Bordered toast',
  border: Border.all(
    color: Colors.blue,
    width: 2,
  ),
);

Persistent Toasts #

MunchToast.show(
  context,
  message: 'Important message',
  persistent: true,  // Requires manual dismiss
  duration: Duration(seconds: 10),  // Max duration before auto-dismiss
);

๐Ÿงช Testing #

Run tests with:

flutter test

๐Ÿ“ฑ Example App #

Check out the complete example app in the /example directory with 9+ e-commerce scenarios and an interactive position selector:

Example App Demo

๐ŸŽฏ Interactive Features #

  • ๐Ÿ“ Position Selector: Choose between Top and Bottom positions with a segmented button
  • ๐Ÿ”„ Real-time Testing: See how toasts adapt to your position preference instantly
  • ๐Ÿ“ฑ Live Examples: All toast types respect your position selection (except Flash Sale & Price Drop which always use top)

Example Scenarios #

  • ๐Ÿ›๏ธ Add to cart confirmation
  • ๐Ÿ’ณ Payment success
  • ๐Ÿ“ฆ Order shipped notifications
  • ๐Ÿ”ฅ Flash sale alerts (always top)
  • โš ๏ธ Low stock warnings
  • โŒ Payment failures
  • ๐Ÿ’ฐ Price drop alerts (always top)
  • ๐Ÿ“ฑ Out of stock notifications
  • ๐ŸŽ Limited time offers

Running the Example #

cd example
flutter run

Try it out:

  1. Open the example app
  2. Use the Toast Position selector at the top
  3. Switch between Top and Bottom
  4. Tap any example card to see toasts appear at your selected position!

๐Ÿค Contributing #

Contributions are welcome! Please read CONTRIBUTING.md for details.

๐Ÿ“„ License #

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments #

  • Built with โค๏ธ for the Flutter community
  • Inspired by modern e-commerce notification patterns
  • Designed with accessibility and performance in mind

๐Ÿ“ž Support #


Made with ๐Ÿž by the MunchToast team

1
likes
155
points
140
downloads

Publisher

verified publishermohammedalojile.com

Weekly Downloads

A modern, highly customizable toast/snackbar notification widget for Flutter, perfect for e-commerce applications.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on munchtoast