TSnackbarService class

A service for displaying snackbar notifications.

TSnackbarService provides snackbar messages with:

  • Success, info, warning, and error variants
  • Customizable action text and onTap callback
  • Custom styling based on the current theme or variant
  • Automatic support for mobile and desktop sizing/spacing

Basic Usage

TSnackbarService.success(context, 'Changes saved successfully');
TSnackbarService.error(context, 'Failed to connect to server');

With Action

TSnackbarService.info(
  context,
  'Message archived',
  actionText: 'Undo',
  onTap: () {
    // Perform undo operation
  },
);

Custom Snackbar

TSnackbarService.show(
  context,
  'Custom notification text',
  title: 'Custom Title',
  icon: Icons.star,
  color: Colors.purple,
  duration: Duration(seconds: 5),
  actionText: 'Retry',
  onTap: () => print('Retry tapped'),
)

Constructors

TSnackbarService()

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

error(BuildContext context, String message, {String? title, String? actionText, VoidCallback? onTap, Duration? duration}) ScaffoldFeatureController<SnackBar, SnackBarClosedReason>
Shows an error/danger snackbar.
info(BuildContext context, String message, {String? title, String? actionText, VoidCallback? onTap, Duration? duration}) ScaffoldFeatureController<SnackBar, SnackBarClosedReason>
Shows an info snackbar.
show(BuildContext context, String message, {String? title, IconData? icon, Duration? duration, Color? color, TVariant? type, String? actionText, VoidCallback? onTap, SnackBarBehavior behavior = SnackBarBehavior.floating, double? elevation, ShapeBorder? shape, EdgeInsetsGeometry? margin, EdgeInsetsGeometry? padding, bool showCloseBtn = false, Alignment? alignment, double? maxWidth}) ScaffoldFeatureController<SnackBar, SnackBarClosedReason>
Shows a custom snackbar notification.
success(BuildContext context, String message, {String? title, String? actionText, VoidCallback? onTap, Duration? duration}) ScaffoldFeatureController<SnackBar, SnackBarClosedReason>
Shows a success snackbar.
warning(BuildContext context, String message, {String? title, String? actionText, VoidCallback? onTap, Duration? duration}) ScaffoldFeatureController<SnackBar, SnackBarClosedReason>
Shows a warning snackbar.