showSnackBar static method

void showSnackBar(
  1. String message, {
  2. Duration duration = const Duration(seconds: 4),
  3. SnackBarAction? action,
  4. Color? backgroundColor,
})

Show a snackbar using the stored context

Implementation

static void showSnackBar(
  String message, {
  Duration duration = const Duration(seconds: 4),
  SnackBarAction? action,
  Color? backgroundColor,
}) {
  final ctx = context;
  if (ctx == null) {
    DebugLogger.log(
      '[DependencyInjection] ⚠️ Cannot show snackbar: No context available',
    );
    return;
  }

  ScaffoldMessenger.of(ctx).showSnackBar(
    SnackBar(
      content: Text(message),
      duration: duration,
      action: action,
      backgroundColor: backgroundColor,
    ),
  );
}