ToastrHelper class
Helper class with convenient methods for showing different types of toastrs.
Zero setup required. Just call static methods from anywhere:
Toastr.success('Operation completed!');
Toastr.error('Something went wrong!');
Toastr.loading('Please wait...');
Toastr.promise(myFuture, loading: 'Loading...', success: 'Done!', error: 'Failed');
All methods return a String toast ID that can be used
with dismiss or update.
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 Properties
- defaultConfig → ToastrConfig
-
Returns the current default configuration (read-only).
no setter
Static Methods
-
blank(
String message, {String? title, Duration? duration, ToastrPosition? position, ToastrShowMethod? showMethod, ToastrHideMethod? hideMethod, Duration? showDuration, Duration? hideDuration, bool? showProgressBar, bool? showCloseButton, bool? preventDuplicates, VoidCallback? onTap, VoidCallback? onDismiss, Widget? content, double? maxWidth, EdgeInsets? margin, Color? accentColor, BoxDecoration? containerDecoration, ToastrTheme? theme, ToastrAction? action, bool? enableHapticFeedback, HapticFeedbackType? hapticFeedbackType, SwipeDismissDirection? swipeDismissDirection, Widget enterAnimationBuilder(Widget child, Animation< double> animation)?, Widget exitAnimationBuilder(Widget child, Animation<double> animation)?, bool? compact, BorderRadius? borderRadius, bool? avoidKeyboard, double? stackOverlap, bool? showCircularProgress, double? gutter, ToastrIconTheme? iconTheme}) → String - Show a blank toastr (plain text, no icon).
-
clearAll(
) → void - Clear all active toastrs
-
clearLast(
) → void - Clear the last (most recent) toastr
-
configure(
{ToastrPosition? position, Duration? duration, Duration? showDuration, Duration? hideDuration, ToastrShowMethod? showMethod, ToastrHideMethod? hideMethod, bool? showProgressBar, bool? showCloseButton, bool? preventDuplicates, double? maxWidth, EdgeInsets? margin, ToastrTheme? theme, bool? reverseOrder, bool? enableHapticFeedback, HapticFeedbackType? hapticFeedbackType, SwipeDismissDirection? swipeDismissDirection, bool? compact, BorderRadius? borderRadius, bool? avoidKeyboard, double? stackOverlap, bool? showCircularProgress, double? gutter, ToastrIconTheme? iconTheme, int? maxVisible}) → void - Configure global defaults for all toastrs
-
custom(
ToastrConfig config) → String - Show a custom toastr with full configuration options.
-
dismiss(
[String? id]) → void -
Dismiss a specific toast by its
id. -
error(
String message, {String? title, Duration? duration, ToastrPosition? position, ToastrShowMethod? showMethod, ToastrHideMethod? hideMethod, Duration? showDuration, Duration? hideDuration, bool? showProgressBar, bool? showCloseButton, bool? preventDuplicates, VoidCallback? onTap, VoidCallback? onDismiss, Widget? content, double? maxWidth, EdgeInsets? margin, Color? accentColor, BoxDecoration? containerDecoration, ToastrTheme? theme, ToastrAction? action, bool? enableHapticFeedback, HapticFeedbackType? hapticFeedbackType, SwipeDismissDirection? swipeDismissDirection, Widget enterAnimationBuilder(Widget child, Animation< double> animation)?, Widget exitAnimationBuilder(Widget child, Animation<double> animation)?, bool? compact, BorderRadius? borderRadius, bool? avoidKeyboard, double? stackOverlap, bool? showCircularProgress, double? gutter, ToastrIconTheme? iconTheme}) → String - Show an error toastr with the given message.
-
info(
String message, {String? title, Duration? duration, ToastrPosition? position, ToastrShowMethod? showMethod, ToastrHideMethod? hideMethod, Duration? showDuration, Duration? hideDuration, bool? showProgressBar, bool? showCloseButton, bool? preventDuplicates, VoidCallback? onTap, VoidCallback? onDismiss, Widget? content, double? maxWidth, EdgeInsets? margin, Color? accentColor, BoxDecoration? containerDecoration, ToastrTheme? theme, ToastrAction? action, bool? enableHapticFeedback, HapticFeedbackType? hapticFeedbackType, SwipeDismissDirection? swipeDismissDirection, Widget enterAnimationBuilder(Widget child, Animation< double> animation)?, Widget exitAnimationBuilder(Widget child, Animation<double> animation)?, bool? compact, BorderRadius? borderRadius, bool? avoidKeyboard, double? stackOverlap, bool? showCircularProgress, double? gutter, ToastrIconTheme? iconTheme}) → String - Show an info toastr with the given message.
-
loading(
String message, {String? title, ToastrPosition? position, ToastrShowMethod? showMethod, ToastrHideMethod? hideMethod, Duration? showDuration, Duration? hideDuration, bool? showCloseButton, VoidCallback? onTap, VoidCallback? onDismiss, Widget? content, double? maxWidth, EdgeInsets? margin, Color? accentColor, BoxDecoration? containerDecoration, ToastrTheme? theme, ToastrAction? action, bool? enableHapticFeedback, HapticFeedbackType? hapticFeedbackType, SwipeDismissDirection? swipeDismissDirection, Widget enterAnimationBuilder(Widget child, Animation< double> animation)?, Widget exitAnimationBuilder(Widget child, Animation<double> animation)?, bool? compact, BorderRadius? borderRadius, bool? avoidKeyboard, double? stackOverlap, bool? showCircularProgress, double? gutter, ToastrIconTheme? iconTheme}) → String - Show a loading toastr with an animated spinner.
-
promise<
T> (Future< T> future, {String loading = 'Loading...', String success = 'Success!', String error = 'Something went wrong', String successBuilder(T data)?, String errorBuilder(Object error)?, ToastrPosition? position, Duration? successDuration, Duration? errorDuration}) → Future<T> - Show a toast that automatically tracks a Future.
-
show(
String message, {ToastrType? type}) → String - Quick method to show a toast with just a message (auto-detects type from message content).
-
success(
String message, {String? title, Duration? duration, ToastrPosition? position, ToastrShowMethod? showMethod, ToastrHideMethod? hideMethod, Duration? showDuration, Duration? hideDuration, bool? showProgressBar, bool? showCloseButton, bool? preventDuplicates, VoidCallback? onTap, VoidCallback? onDismiss, Widget? content, double? maxWidth, EdgeInsets? margin, Color? accentColor, BoxDecoration? containerDecoration, ToastrTheme? theme, ToastrAction? action, bool? enableHapticFeedback, HapticFeedbackType? hapticFeedbackType, SwipeDismissDirection? swipeDismissDirection, Widget enterAnimationBuilder(Widget child, Animation< double> animation)?, Widget exitAnimationBuilder(Widget child, Animation<double> animation)?, bool? compact, BorderRadius? borderRadius, bool? avoidKeyboard, double? stackOverlap, bool? showCircularProgress, double? gutter, ToastrIconTheme? iconTheme}) → String - Show a success toastr with the given message.
-
warning(
String message, {String? title, Duration? duration, ToastrPosition? position, ToastrShowMethod? showMethod, ToastrHideMethod? hideMethod, Duration? showDuration, Duration? hideDuration, bool? showProgressBar, bool? showCloseButton, bool? preventDuplicates, VoidCallback? onTap, VoidCallback? onDismiss, Widget? content, double? maxWidth, EdgeInsets? margin, Color? accentColor, BoxDecoration? containerDecoration, ToastrTheme? theme, ToastrAction? action, bool? enableHapticFeedback, HapticFeedbackType? hapticFeedbackType, SwipeDismissDirection? swipeDismissDirection, Widget enterAnimationBuilder(Widget child, Animation< double> animation)?, Widget exitAnimationBuilder(Widget child, Animation<double> animation)?, bool? compact, BorderRadius? borderRadius, bool? avoidKeyboard, double? stackOverlap, bool? showCircularProgress, double? gutter, ToastrIconTheme? iconTheme}) → String - Show a warning toastr with the given message.