ToastService class

App-wide toast notification service, rendered as an OverlayEntry on the root navigator's Overlay — no BuildContext with a Scaffold ancestor is required at the call site.

All methods accept a localisation key or a raw string. The value is passed through easy_localization's .tr() before display, so passing a key produces a translated message while passing a raw string is returned as-is.

When a mounted BuildContext is available the toast colours are sourced from the active ThemeData; otherwise fallback colours are used. Only one toast is shown at a time — showing a new one dismisses whichever is currently visible.

Constructors

ToastService()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
showErrorToast(String? messageKeyOrText) → void
Shows a long error toast anchored to the bottom of the screen.
showNoInternetToast() → void
Shows the standard no-internet error toast using the 'connectivity.noInternet' key.
showSuccessToast(String messageKeyOrText) → void
Shows a short success toast anchored to the top of the screen.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited