showSnackBar method
void
showSnackBar({
- required String text,
- TextStyle? textStyle,
- Duration? duration,
- Color? color,
- SnackBarAction? action,
- SnackBarBehavior behavior = SnackBarBehavior.fixed,
- Animation<
double> ? animation, - VoidCallback? onVisible,
Show a SnackBar with text
(maximum 2 lines) and color
in the
background. It will stayed for duration
and automatically hides.
If action
is true, a button will appear. The SnackBar will
immediately hide on pressed.
Implementation
void showSnackBar({
required String text,
TextStyle? textStyle,
Duration? duration,
Color? color,
SnackBarAction? action,
SnackBarBehavior behavior = SnackBarBehavior.fixed,
Animation<double>? animation,
VoidCallback? onVisible,
}) {
hideAll();
final snackBar = SnackBar(
content: Text(
text,
maxLines: customTheme.maxLines,
overflow: TextOverflow.ellipsis,
style: textStyle ?? customTheme.textStyle,
),
backgroundColor: color,
duration: duration ?? customTheme.defaultDuration,
behavior: behavior,
animation: animation,
onVisible: onVisible,
action: action == null
? customTheme.showDefaultAction
? SnackBarAction(
label: "CLEAR",
onPressed: hideAll,
)
: null
: action,
);
showRawSnackBar(snackBar);
}