Skip to content

Toast

Non-intrusive brief notification banner supporting status icons, formatted text, and timed auto-dismiss.

Overview

Toast provides transient, non-intrusive status messages that automatically disappear after a specified timeout.

Key features: - Plain and rich-text message formatting. - Configurable auto-dismiss duration and fade transitions. - Optional status icon and custom actions. - Stackable integration within NotificationView.

Showing Auto-Dismissing Toast Notification

Toast toast = new Toast("Settings saved successfully!");
toast.duration(3.0f).show();
  • NotificationView: Rich notification card widget rendering severity icons, titles, messages, action buttons, and auto-dismiss progress.
  • OverlayLayer: Full-screen overlay root managing modal backdrops, dialogs, popups, and layer-based hit testing.

API

Toast()

Constructs an empty Toast widget initialized with default styling.

Toast(String)

Constructs a Toast with the specified message text.

Parameter Type Description
text String Display text string.

Toast::arrangeInHost(RectView)

Positions the toast anchored to the bottom-right corner of the host container.

Parameter Type Description
hostBounds RectView Available host rectangular boundary.

Toast::duration()

Returns the toast lifetime in seconds.

Returns float: Display duration in seconds..

Toast::duration(float)

Sets the toast lifetime in seconds before auto-dismissal (0 keeps it open indefinitely).

Parameter Type Description
seconds float Display duration in seconds before auto-dismissal.

Returns Toast: This widget instance for chaining..

Toast::hide()

Hides the toast immediately.

Returns Toast: This widget instance for chaining..

Toast::margin()

Returns the margin distance from host edges in UI pixels.

Returns float: Margin distance in pixels..

Toast::margin(float)

Sets the margin distance from host edges in UI pixels.

Parameter Type Description
margin float External margin distance.

Returns Toast: This widget instance for chaining..

Toast::opened()

Returns true if the toast is currently visible and active.

Returns boolean: True if currently open..

Toast::preferredSize(float, float)

Sets the preferred dimensions of the toast card in UI pixels.

Parameter Type Description
width float Width dimension in pixels.
height float Height dimension in pixels.

Returns Toast: This widget instance for chaining..

Toast::show()

Shows the toast and resets its elapsed time counter.

Returns Toast: This widget instance for chaining..

Toast::text()

Returns the toast message text.

Returns String: The displayed text string..

Toast::text(String)

Sets the toast message text.

Parameter Type Description
text String Display text string.

Returns Toast: This widget instance for chaining..

Toast::toast(String)

Updates message text and immediately displays the toast with animation.

Parameter Type Description
text String Display text string.

Returns Toast: This widget instance for chaining..