showSnackBar method
void
showSnackBar(
- String message, {
- Duration duration = const Duration(seconds: 3),
- SnackBarAction? action,
- Color? backgroundColor,
- Color? textColor,
Shows a snackbar with the given message.
Example:
context.showSnackBar('Hello!');
context.showSnackBar('Hello!', duration: Duration(seconds: 5));
Implementation
void showSnackBar(
String message, {
Duration duration = const Duration(seconds: 3),
SnackBarAction? action,
Color? backgroundColor,
Color? textColor,
}) {
ScaffoldMessenger.of(this).showSnackBar(
SnackBar(
content: Text(message, style: textColor != null ? TextStyle(color: textColor) : null),
duration: duration,
action: action,
backgroundColor: backgroundColor,
),
);
}