Skip to Content

Snackbar

A brief notification bar that appears temporarily at the bottom of the screen. Supports an optional action button that the user can tap. After Duration seconds the snackbar hides itself and invokes OnDismiss so the caller can remove it from the tree.

Constructor

Snackbar

Creates a Snackbar element.

ParameterDescription
messageThe notification text. Must not be null.
actionLabelLabel for the optional action button.
onActionCallback invoked when the action button is tapped.
durationVisible duration in seconds. Defaults to 4.
onDismissCallback invoked after auto-dismiss. Use to remove the snackbar from the tree.
keyAn optional key for reconciliation identity.

Properties

ActionLabel

The label for the optional action button. Null means no action button is shown.

Duration

How long the snackbar remains visible, in seconds. Defaults to 4 seconds.

Message

The message text displayed in the snackbar.

OnAction

Callback invoked when the user taps the action button. Only relevant when ActionLabel is non-null.

OnDismiss

Callback invoked after the snackbar auto-dismisses. Use this to remove the snackbar from the tree. Optional — the snackbar hides itself regardless.

Methods

CreateState

Last updated on