ToastManager class
A utility class for managing the display of toast notifications within a Flutter application.
This class provides a convenient way to show toasts with customizable appearances, actions, and durations.
The show method allows you to display a toast with custom messages, duration, position, style, and more.
Example usage:
ToastManager.show(
context: context,
message: "Event has been created",
description: "Sunday, December 03, 2023 at 9:00 AM",
duration: Duration(seconds: 3),
position: ToastPosition.bottom,
type: ToastType.success, // Choose the toast type
icon: Icon(Icons.check_circle, color: Colors.white), // Optional icon
onTap: () {
print("Toast tapped!");
},
);
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
clear(
) → void - Clears all active toasts from the screen.
-
show(
{required BuildContext context, required String message, String? description, Duration duration = const Duration(seconds: 2), ToastPosition position = ToastPosition.bottom, ToastType type = ToastType.info, TextStyle textStyle = const TextStyle(color: Colors.white), BorderRadiusGeometry borderRadius = const BorderRadius.all(Radius.circular(8)), Widget? icon, VoidCallback? onTap}) → void - Displays a toast with customizable parameters.