toastr_flutter 1.0.0+7 copy "toastr_flutter: ^1.0.0+7" to clipboard
toastr_flutter: ^1.0.0+7 copied to clipboard

A highly customizable Flutter package for displaying beautiful toast notifications with smooth animations, multiple types, and flexible positioning. Works like SnackBar with no initialization required.

Toastr Flutter ๐Ÿž #

A highly customizable Flutter package for displaying beautiful toast notifications with smooth animations, multiple types, and flexible positioning. Works like Flutter's SnackBar - no initialization required!

pub package License: Apache 2.0

Features โœจ #

  • ๐ŸŽจ Multiple notification types: Success, Error, Warning, Info
  • ๐Ÿ“ Flexible positioning: Top/Bottom with Left/Center/Right alignment
  • ๐ŸŽญ Smooth animations: Fade and slide animations with custom easing
  • ๐ŸŽฏ Highly customizable: Colors, icons, duration, progress bars, and more
  • ๐Ÿ‘† Interactive: Tap to dismiss and close button functionality
  • ๐Ÿงช Well tested: Comprehensive test coverage
  • ๐Ÿ“ฑ Responsive: Adaptive design for mobile, tablet, and desktop
  • ๐Ÿš€ Zero setup: Just pass context like SnackBar - no initialization needed!
  • ๐Ÿ”’ Secure: No auto-detection, no performance overhead

Installation ๐Ÿ“ฆ #

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

dependencies:
  toastr_flutter: ^1.0.0

Then run:

flutter pub get

Quick Start ๐Ÿš€ #

Basic Usage #

Simply import the package and start using it anywhere in your app with BuildContext:

import 'package:flutter/material.dart';
import 'package:toastr_flutter/toastr.dart';

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Toastr Example')),
      body: Center(
        child: Column(
          children: [
            ElevatedButton(
              onPressed: () => ToastrHelper.success(context, 'Success!'),
              child: Text('Show Success'),
            ),
            ElevatedButton(
              onPressed: () => ToastrHelper.error(context, 'Error occurred!'),
              child: Text('Show Error'),
            ),
          ],
        ),
      ),
    );
  }
}

All Available Methods #

// Success notification (green)
ToastrHelper.success(context, 'Operation completed successfully!');

// Error notification (red)
ToastrHelper.error(context, 'Something went wrong!');

// Warning notification (orange)
ToastrHelper.warning(context, 'Please check your input');

// Info notification (blue)
ToastrHelper.info(context, 'Here is some useful information');

// Auto-detect type from message content
ToastrHelper.show(context, 'Success! Operation completed'); // Automatically shows green success

// Custom configuration
ToastrHelper.custom(context, ToastrConfig(...));

Advanced Usage ๐Ÿ”ง #

Custom Configuration #

For complete control over appearance and behavior:

ToastrHelper.custom(context, ToastrConfig(
  type: ToastrType.success,
  message: 'Custom styled notification',
  title: 'Custom Title',
  duration: Duration(seconds: 5),
  position: ToastrPosition.topRight,
  showMethod: ToastrShowMethod.fadeIn,
  hideMethod: ToastrHideMethod.fadeOut,
  showDuration: Duration(milliseconds: 300),
  hideDuration: Duration(milliseconds: 1000),
  showProgressBar: true,
  showCloseButton: true,
  preventDuplicates: true,
));

Method Parameters #

All helper methods support these optional parameters:

ToastrHelper.success(
  context,                    // Required: BuildContext
  'Your message here',        // Required: String message
  title: 'Optional Title',    // Optional: String title
  duration: Duration(seconds: 3),       // Optional: How long to show
  position: ToastrPosition.topRight,    // Optional: Where to show
  showMethod: ToastrShowMethod.fadeIn,  // Optional: Show animation
  hideMethod: ToastrHideMethod.fadeOut, // Optional: Hide animation
  showDuration: Duration(milliseconds: 300),  // Optional: Animation duration
  hideDuration: Duration(milliseconds: 1000), // Optional: Hide animation duration
  showProgressBar: false,     // Optional: Show progress bar
  showCloseButton: false,     // Optional: Show close button
  preventDuplicates: false,   // Optional: Prevent duplicate messages
);

Positioning Options #

Choose where your notifications appear:

// Top positions
ToastrPosition.topLeft      // Top-left corner
ToastrPosition.topCenter    // Top-center
ToastrPosition.topRight     // Top-right corner (default)

// Bottom positions
ToastrPosition.bottomLeft   // Bottom-left corner
ToastrPosition.bottomCenter // Bottom-center
ToastrPosition.bottomRight  // Bottom-right corner

Animation Options #

Customize how notifications appear and disappear:

// Show methods
ToastrShowMethod.fadeIn     // Fade in (default)
ToastrShowMethod.slideDown  // Slide down from top
ToastrShowMethod.slideUp    // Slide up from bottom

// Hide methods
ToastrHideMethod.fadeOut    // Fade out (default)
ToastrHideMethod.slideUp    // Slide up
ToastrHideMethod.slideDown  // Slide down

Managing Notifications #

// Clear all active notifications
ToastrHelper.clearAll();

// Clear only the last notification
ToastrHelper.clearLast();

API Reference ๐Ÿ“š #

ToastrHelper Methods #

Method Description Parameters
success(context, message, {...}) Show green success notification context, message, optional params
error(context, message, {...}) Show red error notification context, message, optional params
warning(context, message, {...}) Show orange warning notification context, message, optional params
info(context, message, {...}) Show blue info notification context, message, optional params
show(context, message, {type}) Auto-detect type from content context, message, optional type
custom(context, config) Show with full custom config context, ToastrConfig object
clearAll() Clear all active notifications None
clearLast() Clear only the last notification None

ToastrConfig Properties #

Configuration class for complete customization:

Property Type Default Description
type ToastrType required success, error, warning, info
message String required Main message text
title String? null Optional title text
duration Duration 5 seconds How long to display
position ToastrPosition topRight Where to position
showMethod ToastrShowMethod fadeIn Show animation type
hideMethod ToastrHideMethod fadeOut Hide animation type
showDuration Duration 300ms Show animation duration
hideDuration Duration 1000ms Hide animation duration
showProgressBar bool false Show progress bar
showCloseButton bool false Show close button
preventDuplicates bool false Prevent duplicate messages

Responsive Design ๐Ÿ“ฑ #

The package automatically adapts to different screen sizes:

  • Mobile (< 768px): Optimized spacing and sizing
  • Tablet (768px - 1024px): Medium sizing with appropriate margins
  • Desktop (> 1024px): Full-featured with optimal positioning

Examples ๐Ÿ’ก #

Quick Notifications #

// In any widget with BuildContext
ElevatedButton(
  onPressed: () => ToastrHelper.success(context, 'Saved successfully!'),
  child: Text('Save'),
)

// Error with custom duration
ElevatedButton(
  onPressed: () => ToastrHelper.error(
    context, 
    'Failed to save!',
    duration: Duration(seconds: 10),
  ),
  child: Text('Save'),
)

Advanced Notifications #

// Custom notification with all features
ToastrHelper.custom(context, ToastrConfig(
  type: ToastrType.info,
  title: 'Update Available',
  message: 'A new version of the app is available. Update now?',
  duration: Duration(seconds: 10),
  position: ToastrPosition.bottomCenter,
  showProgressBar: true,
  showCloseButton: true,
  preventDuplicates: true,
  showMethod: ToastrShowMethod.slideUp,
  hideMethod: ToastrHideMethod.fadeOut,
));

Screenshots ๐Ÿ“ธ #

๐Ÿ–ฅ๏ธ Desktop Experience #

Configuration Panel

Desktop Configuration Panel
Comprehensive customization options
Toast Notifications

Desktop Toast Notifications
Beautiful notifications in action

๐Ÿ“ฑ Mobile Experience #

Mobile Interface

Mobile Interface
Responsive mobile design
Mobile Toasts

Mobile Toast Notifications
Perfect mobile adaptation

๐ŸŽจ Responsive Design: Automatically adapts to different screen sizes - from mobile phones to desktop computers with consistent behavior and beautiful animations.

Migration Guide ๐Ÿ”„ #

From v1.0.0+2 to v1.0.0+3 #

Breaking Change: All methods now require BuildContext as first parameter.

Before:

ToastrHelper.success('Message');
ToastrHelper.error('Error');

After:

ToastrHelper.success(context, 'Message');
ToastrHelper.error(context, 'Error');

Benefits:

  • โœ… No more manual initialization required
  • โœ… Better performance (no auto-detection overhead)
  • โœ… More secure (no background scanning)
  • โœ… Works exactly like Flutter's SnackBar

License ๐Ÿ“„ #

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

Contributing ๐Ÿค #

Contributions are welcome! Please feel free to submit a Pull Request.


Made with โค๏ธ by Ignacio Manchu

0
likes
150
points
37
downloads
screenshot

Publisher

verified publisherignacio-manchu.com

Weekly Downloads

A highly customizable Flutter package for displaying beautiful toast notifications with smooth animations, multiple types, and flexible positioning. Works like SnackBar with no initialization required.

Repository (GitHub)
View/report issues

Topics

#toast #notification #snackbar #alert #ui

Documentation

Documentation
API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on toastr_flutter