XSnackbar class

A utility class for displaying styled snackbars at the top or bottom of the screen. Works with Overlay for top-positioned snackbars and uses the native Flutter SnackBar for bottom-positioned snackbars.

Attach the provided navigatorKey to your MaterialApp:

MaterialApp(
  navigatorKey: XSnackbar.navigatorKey,
  home: MyApp(),
)

Usage examples:

XSnackbar.info('Saved!');
XSnackbar.error('Something went wrong', title: 'Error');
XSnackbar.custom('Hello', color: Colors.purple);
XSnackbar.success('Done', position: XSnackbarPosition.top);

Constructors

XSnackbar()

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 Properties

A global key that must be assigned to the app's MaterialApp in order for XSnackbar to access the current NavigatorState.
final

Static Methods

custom(String message, {String? title, Color color = Colors.lightBlue, XSnackbarPosition position = XSnackbarPosition.bottom, XSnackbarConfig config = const XSnackbarConfig(), VoidCallback? onAction}) → void
Shows a snackbar with a custom color.
error(String message, {String? title, XSnackbarPosition position = XSnackbarPosition.bottom, XSnackbarConfig config = const XSnackbarConfig(), VoidCallback? onAction}) → void
Shows an error snackbar (red colored).
info(String message, {String? title, XSnackbarPosition position = XSnackbarPosition.bottom, XSnackbarConfig config = const XSnackbarConfig(), VoidCallback? onAction}) → void
Shows an informational snackbar.
success(String message, {String? title, XSnackbarPosition position = XSnackbarPosition.bottom, XSnackbarConfig config = const XSnackbarConfig(), VoidCallback? onAction}) → void
Shows a success snackbar (green colored).
warning(String message, {String? title, XSnackbarPosition position = XSnackbarPosition.bottom, XSnackbarConfig config = const XSnackbarConfig(), VoidCallback? onAction}) → void
Shows a warning snackbar (orange colored).