ToastrOptions class
Optional parameters for customizing a toast notification.
Pass an instance to any Toastr method as the optional second argument:
Toastr.success('Saved!', ToastrOptions(duration: Duration(seconds: 2)));
Toastr.error('Failed', ToastrOptions(position: ToastrPosition.bottomCenter));
Constructors
-
ToastrOptions({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, TextStyle? titleStyle, TextStyle? messageStyle}) -
Creates a set of optional toast customization parameters.
const
Properties
- accentColor → Color?
-
Accent color for the progress bar and icon background.
final
- action → ToastrAction?
-
Optional action button displayed inside the toast.
final
- avoidKeyboard → bool?
-
Automatically shift the toast above the software keyboard when visible.
final
- borderRadius → BorderRadius?
-
Custom border radius, overriding the default
BorderRadius.circular(8).final - compact → bool?
-
Use reduced padding, font, and icon sizes.
final
- containerDecoration → BoxDecoration?
-
Custom BoxDecoration that replaces the default toast container style.
final
- content → Widget?
-
Fully custom widget shown instead of the text message.
final
- duration → Duration?
-
How long the toast stays visible. Ignored for loading toasts.
final
- enableHapticFeedback → bool?
-
Whether to trigger haptic feedback when the toast appears.
final
-
enterAnimationBuilder
→ Widget Function(Widget child, Animation<
double> animation)? -
Custom enter animation. Receives the child and a 0→1 animation value.
final
-
exitAnimationBuilder
→ Widget Function(Widget child, Animation<
double> animation)? -
Custom exit animation. Receives the child and a 0→1 animation value.
final
- gutter → double?
-
Spacing in logical pixels between stacked toasts (mirrors react-hot-toast's
gutter).final - hapticFeedbackType → HapticFeedbackType?
-
Which haptic pattern to use when enableHapticFeedback is
true.final - hashCode → int
-
The hash code for this object.
no setterinherited
- hideDuration → Duration?
-
Duration of the exit animation.
final
- hideMethod → ToastrHideMethod?
-
Animation used when the toast exits.
final
- iconTheme → ToastrIconTheme?
-
Custom icon colors, overriding the type-based defaults.
final
- margin → EdgeInsets?
-
Offset from the screen edges for the position group.
final
- maxWidth → double?
-
Maximum width of the toast container in logical pixels.
final
- messageStyle → TextStyle?
-
Custom TextStyle for the toast message.
Merged on top of the default style — only set fields are overridden.
final
- onDismiss → VoidCallback?
-
Called when the toast is dismissed by any means.
final
- onTap → VoidCallback?
-
Called when the toast is tapped.
final
- position → ToastrPosition?
-
Where on screen the toast appears.
final
- preventDuplicates → bool?
-
When
true, toasts with the same type+title+message are deduplicated.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showCircularProgress → bool?
-
Show a circular countdown indicator instead of a linear progress bar.
final
- showCloseButton → bool?
-
Whether to show an explicit close (×) button.
final
- showDuration → Duration?
-
Duration of the enter animation.
final
- showMethod → ToastrShowMethod?
-
Animation used when the toast enters.
final
- showProgressBar → bool?
-
Whether to show a linear progress bar at the bottom of the toast.
final
- stackOverlap → double?
-
Vertical overlap in logical pixels between stacked toasts.
final
- swipeDismissDirection → SwipeDismissDirection?
-
Direction the user can swipe to dismiss the toast.
final
- theme → ToastrTheme?
-
Light or dark color theme.
final
- title → String?
-
Optional title shown above the message.
final
- titleStyle → TextStyle?
-
Custom TextStyle for the toast title.
Merged on top of the default style — only set fields are overridden.
final
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