hz_toast library

A highly customizable and feature-rich toast notification package for Flutter.

This library provides a complete solution for displaying toast notifications in Flutter applications with extensive customization options, smooth animations, and interactive features.

Key Features

  • Multiple Toast Types: Error, Success, Warning, and Info with predefined color schemes
  • Fully Customizable: Colors, icons, decorations, padding, margins, and more
  • Auto-hide with Progress Bar: Optional progress bar showing remaining time
  • Dynamic Updates: Update toast content while it's displayed
  • Responsive: Adapts to different screen sizes with configurable max width
  • Smooth Animations: Beautiful slide and fade animations
  • Interactive: Clickable toasts with custom tap handlers
  • Positioned: Top-right positioned toasts that stack properly
  • Builder Pattern: Custom builders for title, icons, and close buttons

Basic Usage

// Show a simple success toast
HzToast.show(HzToastData(
  'Operation completed successfully!',
  type: HzToastType.success,
));

// Show an error toast with custom styling
HzToast.show(HzToastData(
  'Something went wrong!',
  type: HzToastType.error,
  duration: Duration(seconds: 5),
  showProgressBar: true,
));

Setup

Wrap your app with HzToastInitializer:

MaterialApp(
  builder: (context, child) {
    return HzToastInitializer(child: child!);
  },
  home: MyHomePage(),
)

Classes

HzToast
A singleton class that manages toast notifications throughout the application.
HzToastData
Configuration data for a toast notification.
HzToastInitializer
Widget that initializes the toast system for the entire app.
HzToastWidget
A widget that displays and manages toast notifications in an overlay.

Enums

HzToastAlignment
Defines the positioning of toast notifications on the screen.
HzToastType
Defines the visual style and behavior of a toast notification.