CNToast class

A native toast notification widget.

Toasts are lightweight, non-intrusive notifications that appear briefly and auto-dismiss. Unlike snackbars, they don't require user interaction and are typically positioned in the center or top of the screen.

On iOS 26+, supports Liquid Glass effects for a native look.

Basic Usage

CNToast.show(
  context: context,
  message: 'Settings saved',
);

With Icon

CNToast.show(
  context: context,
  message: 'Copied to clipboard',
  icon: Icon(CupertinoIcons.doc_on_clipboard_fill),
);

Success Toast

CNToast.success(
  context: context,
  message: 'Profile updated successfully',
);

Error Toast

CNToast.error(
  context: context,
  message: 'Failed to save changes',
);

Custom Position

CNToast.show(
  context: context,
  message: 'New message',
  position: CNToastPosition.top,
);

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
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

clear() → void
Clears all active toasts.
error({required BuildContext context, required String message, CNToastPosition position = CNToastPosition.center, CNToastDuration duration = CNToastDuration.medium, bool useGlassEffect = true}) → void
Shows an error toast.
info({required BuildContext context, required String message, CNToastPosition position = CNToastPosition.center, CNToastDuration duration = CNToastDuration.medium, bool useGlassEffect = true}) → void
Shows an info toast.
loading({required BuildContext context, String message = 'Loading...', CNToastPosition position = CNToastPosition.center, bool useGlassEffect = true}) CNLoadingToastHandle
Shows a loading toast that must be dismissed manually.
show({required BuildContext context, required String message, Widget? icon, CNToastPosition position = CNToastPosition.center, CNToastDuration duration = CNToastDuration.medium, CNToastStyle style = CNToastStyle.normal, Color? backgroundColor, Color? textColor, bool useGlassEffect = true}) → void
Shows a toast with the given message.
success({required BuildContext context, required String message, CNToastPosition position = CNToastPosition.center, CNToastDuration duration = CNToastDuration.medium, bool useGlassEffect = true}) → void
Shows a success toast.
warning({required BuildContext context, required String message, CNToastPosition position = CNToastPosition.center, CNToastDuration duration = CNToastDuration.medium, bool useGlassEffect = true}) → void
Shows a warning toast.