ToastrHelper class
Helper class with convenient methods for showing different types of toastrs.
This class provides static methods for quickly displaying toast notifications without needing to create ToastrConfig objects manually. All methods require a BuildContext as the first parameter, similar to Flutter's SnackBar.
Example usage:
ToastrHelper.success(context, 'Operation completed!');
ToastrHelper.error(context, 'Something went wrong!');
ToastrHelper.warning(context, 'Please check your input');
ToastrHelper.info(context, 'Here is some information');
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
-
Default configuration that can be customized globally
getter/setter pair
Static Methods
-
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}) → void - Configure global defaults for all toastrs
-
custom(
BuildContext context, ToastrConfig config) → void - Show a custom toastr with full configuration options
-
error(
BuildContext context, String message, {String? title, Duration? duration, ToastrPosition? position, ToastrShowMethod? showMethod, ToastrHideMethod? hideMethod, Duration? showDuration, Duration? hideDuration, bool? showProgressBar, bool? showCloseButton, bool? preventDuplicates}) → void - Show an error toastr with the given message
-
info(
BuildContext context, String message, {String? title, Duration? duration, ToastrPosition? position, ToastrShowMethod? showMethod, ToastrHideMethod? hideMethod, Duration? showDuration, Duration? hideDuration, bool? showProgressBar, bool? showCloseButton, bool? preventDuplicates}) → void - Show an info toastr with the given message
-
show(
BuildContext context, String message, {ToastrType? type}) → void - Quick method to show a toast with just a message (auto-detects type from message content)
-
success(
BuildContext context, String message, {String? title, Duration? duration, ToastrPosition? position, ToastrShowMethod? showMethod, ToastrHideMethod? hideMethod, Duration? showDuration, Duration? hideDuration, bool? showProgressBar, bool? showCloseButton, bool? preventDuplicates}) → void - Show a success toastr with the given message
-
warning(
BuildContext context, String message, {String? title, Duration? duration, ToastrPosition? position, ToastrShowMethod? showMethod, ToastrHideMethod? hideMethod, Duration? showDuration, Duration? hideDuration, bool? showProgressBar, bool? showCloseButton, bool? preventDuplicates}) → void - Show a warning toastr with the given message