snackBar function
void
snackBar(
- BuildContext context,
- {String title = '',
- Widget? content,
- SnackBarAction? snackBarAction,
- Function? onVisible,
- Color? textColor,
- Color? backgroundColor,
- EdgeInsets? margin,
- EdgeInsets? padding,
- Animation<
double> ? animation, - double? width,
- ShapeBorder? shape,
- Duration? duration,
- SnackBarBehavior? behavior,
- double? elevation}
Show SnackBar
Implementation
void snackBar(
BuildContext context, {
String title = '',
Widget? content,
SnackBarAction? snackBarAction,
Function? onVisible,
Color? textColor,
Color? backgroundColor,
EdgeInsets? margin,
EdgeInsets? padding,
Animation<double>? animation,
double? width,
ShapeBorder? shape,
Duration? duration,
SnackBarBehavior? behavior,
double? elevation,
}) {
if (title.isEmpty && content == null) {
log('SnackBar message is empty');
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: backgroundColor,
action: snackBarAction,
margin: margin,
animation: animation,
width: width,
shape: shape,
duration: duration ?? 4.seconds,
behavior: margin != null ? SnackBarBehavior.floating : behavior,
elevation: elevation,
onVisible: onVisible?.call(),
content: content ??
Padding(
padding: padding ?? EdgeInsets.symmetric(vertical: 4),
child: Text(
title,
style: primaryTextStyle(color: textColor ?? Colors.white),
),
),
),
);
}
}