import "package:flutter/material.dart"; /// Errors get the error color explicitly — the theme's default SnackBar is /// neutral, so a plain SnackBar(content: ...) is *not* red anymore. void showErrorSnackBar(BuildContext context, String message, {Duration? duration}) { final scheme = Theme.of(context).colorScheme; ScaffoldMessenger.of(context).showSnackBar( SnackBar( backgroundColor: scheme.error, duration: duration ?? const Duration(seconds: 4), content: Text(message, style: TextStyle(color: scheme.onError)), ), ); }