ToastrConfig class

Configuration class for toastr notifications.

Contains all settings for customizing the appearance, behavior, and animation of toastr notifications. This class is immutable and uses the copyWith pattern for creating modified versions.

Example:

final config = ToastrConfig(
  type: ToastrType.success,
  message: 'Operation completed',
  duration: Duration(seconds: 3),
  position: ToastrPosition.topRight,
);

Constructors

ToastrConfig({required ToastrType type, required String message, String? title, Duration duration = const Duration(seconds: 5), Duration? extendedTimeout, bool dismissible = true, bool showCloseButton = false, Widget? customIcon, Color? backgroundColor, Color? textColor, Duration showDuration = const Duration(milliseconds: 300), Duration hideDuration = const Duration(milliseconds: 1000), ToastrPosition position = ToastrPosition.topRight, ToastrShowMethod showMethod = ToastrShowMethod.fadeIn, ToastrHideMethod hideMethod = ToastrHideMethod.fadeOut, Curve showEasing = Curves.easeOut, Curve hideEasing = Curves.easeIn, bool showProgressBar = false, bool preventDuplicates = false, String? duplicateKey, VoidCallback? onTap, VoidCallback? onDismiss, Widget? content, double maxWidth = 350, EdgeInsets? margin, Color? accentColor, BoxDecoration? containerDecoration, ToastrTheme theme = ToastrTheme.light, bool reverseOrder = false, ToastrAction? action, bool enableHapticFeedback = false, HapticFeedbackType hapticFeedbackType = HapticFeedbackType.light, SwipeDismissDirection swipeDismissDirection = SwipeDismissDirection.horizontal, Widget enterAnimationBuilder(Widget child, Animation<double> animation)?, Widget exitAnimationBuilder(Widget child, Animation<double> animation)?, bool compact = false, BorderRadius? borderRadius, bool avoidKeyboard = true, double? stackOverlap, bool showCircularProgress = false, double gutter = 8, ToastrIconTheme? iconTheme})
Creates a new ToastrConfig with the specified parameters.
const

Properties

accentColor Color?
Custom accent color for progress bar and icon background
final
action ToastrAction?
Optional action button displayed inside the toast
final
avoidKeyboard bool
Whether to automatically move the toast above the keyboard when it appears.
final
backgroundColor Color?
Custom background color to override the default type color
final
borderRadius BorderRadius?
Custom border radius for the toast container. When set, overrides the default BorderRadius.circular(8).
final
compact bool
Use compact layout with reduced padding, font and icon sizes.
final
containerDecoration BoxDecoration?
Custom container decoration to override the default style
final
content Widget?
Custom widget content to display instead of the text message
final
customIcon Widget?
Custom icon to override the default type icon
final
dismissible bool
Whether the toastr can be dismissed by tapping
final
duplicateKey String?
Unique identifier for preventing duplicates
final
duration Duration
Duration for which the toastr should be visible
final
enableHapticFeedback bool
Whether to trigger haptic feedback when the toast appears
final
enterAnimationBuilder Widget Function(Widget child, Animation<double> animation)?
Custom enter animation builder. Receives the child widget and animation value (0→1).
final
exitAnimationBuilder Widget Function(Widget child, Animation<double> animation)?
Custom exit animation builder. Receives the child widget and animation value (0→1).
final
extendedTimeout Duration?
Extended timeout when hovering over the toast
final
gutter double
Spacing (in logical pixels) between stacked toasts at the same position. Mirrors react-hot-toast's gutter prop.
final
hapticFeedbackType HapticFeedbackType
Type of haptic feedback to trigger
final
hashCode int
The hash code for this object.
no setterinherited
hideDuration Duration
Animation duration for hide
final
hideEasing Curve
Hide easing curve
final
hideMethod ToastrHideMethod
Hide animation type
final
iconTheme ToastrIconTheme?
Custom icon theme to override type-based icon colors. ToastrIconTheme.primary sets the circle/background color. ToastrIconTheme.secondary sets the checkmark/line color.
final
key String
Generates a key for duplicate detection
no setter
margin EdgeInsets?
Custom margin/offset from screen edges
final
maxWidth double
Maximum width of the toast (default: 350)
final
message String
The message to display
final
onDismiss VoidCallback?
Callback invoked when the toast is dismissed (by any means)
final
onTap VoidCallback?
Callback invoked when the toast is tapped (before dismiss)
final
position ToastrPosition
Position of the toastr on screen
final
preventDuplicates bool
Whether the notification should prevent duplicates
final
reverseOrder bool
Whether new toasts should appear at the bottom of the stack
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showCircularProgress bool
Whether to show a circular countdown progress indicator instead of a linear bar.
final
showCloseButton bool
Whether to show a close button
final
showDuration Duration
Animation duration for show
final
showEasing Curve
Show easing curve
final
showMethod ToastrShowMethod
Show animation type
final
showProgressBar bool
Whether to enable progress bar
final
stackOverlap double?
Vertical overlap (in logical pixels) between stacked toasts at the same position. Positive values make toasts overlap by that amount.
final
swipeDismissDirection SwipeDismissDirection
Direction in which the toast can be swiped to dismiss
final
textColor Color?
Custom text color
final
theme ToastrTheme
Color theme for the toast (light or dark)
final
title String?
Optional title for the notification
final
type ToastrType
The type of toastr notification
final

Methods

copyWith({ToastrType? type, String? message, String? title, Duration? duration, Duration? extendedTimeout, bool? dismissible, bool? showCloseButton, Widget? customIcon, Color? backgroundColor, Color? textColor, Duration? showDuration, Duration? hideDuration, ToastrPosition? position, ToastrShowMethod? showMethod, ToastrHideMethod? hideMethod, Curve? showEasing, Curve? hideEasing, bool? showProgressBar, bool? preventDuplicates, String? duplicateKey, VoidCallback? onTap, VoidCallback? onDismiss, Widget? content, double? maxWidth, EdgeInsets? margin, Color? accentColor, BoxDecoration? containerDecoration, ToastrTheme? theme, bool? reverseOrder, 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}) ToastrConfig
Creates a copy of this config with updated values
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