Toast
A Toast is a brief notification that appears temporarily to inform users of a process, action, or state change.
Use Toasts to provide non-intrusive feedback without blocking the user’s current task, ideal for confirmations, status updates, and reminders.
Common alternative names:
Snackbar, Notification, Banner
Variants
Section titled “Variants”Subtle
Section titled “Subtle”Basic toast with default subtle styling.
Toast.show( context, type: ToastType.subtle, message: 'This is a snack bar',);Contrast Toast
Section titled “Contrast Toast”Toast with contrasting background for better visibility.
Toast.show( context, type: ToastType.contrast, message: 'This is a snack bar',);Accent Toast
Section titled “Accent Toast”Toast with accent color background for important messages.
Toast.show( context, type: ToastType.accent, message: 'This is a snack bar',);With Caption
Section titled “With Caption”Toast with an additional caption text.
Toast.show( context, type: ToastType.contrast, message: 'This is a snack bar', caption: 'Caption',);Action Text
Section titled “Action Text”Toast with a text action button.
Toast.show( context, message: 'This is a snack bar', actionText: 'Action', onActionPressed: () {},);Action Icon
Section titled “Action Icon”Toast with an icon button action.
Toast.show( context, message: 'This is a snack bar', actionIcon: Icon( Icons.arrow_forward_ios, size: 16, color: context.color.accentModerate, ), onActionPressed: () {},);Leading Icon
Section titled “Leading Icon”Toast with a leading icon.
Toast.show( context, message: 'This is a snack bar', leadingIcon: SvgPicture.asset('assets/circle.svg'),);Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
message | String | The main text displayed in the toast. |
caption | String? | Optional secondary text shown below the main message. |
type | ToastType | Visual style of the toast. |
leadingIcon | Widget? | Optional icon widget displayed at the start of the toast. |
actionText | String? | Text for the optional action button. |
onActionPressed | VoidCallback? | Callback function when the action button is pressed. |
actionIcon | Widget? | Optional icon widget for the action instead of text. |
duration | Duration | Time before the toast auto-dismisses. Default: 4 seconds. |
margin | EdgeInsets? | Custom margin around the toast container. |
padding | EdgeInsets? | Custom padding inside the toast container. |
borderRadius | BorderRadius? | Custom border radius for the toast container. |
elevation | double? | Custom elevation (shadow) for the toast. |
messageStyle | TextStyle? | Custom text style for the main message. |
captionStyle | TextStyle? | Custom text style for the caption. |
actionTextStyle | TextStyle? | Custom text style for the action button text. |