showInAppNotification static method
void
showInAppNotification({
- String? title,
- String? body,
- SnackBarAction? action,
- TextStyle? titleTextStyle,
- TextStyle? bodyTextStyle,
- Duration duration = const Duration(seconds: 5),
- EdgeInsetsGeometry? margin,
- SnackBarBehavior? behavior,
- ShapeBorder? shape,
- DismissDirection dismissDirection = DismissDirection.down,
- Color? backgroundColor,
Implementation
static void showInAppNotification({
String? title,
String? body,
SnackBarAction? action,
TextStyle? titleTextStyle,
TextStyle? bodyTextStyle,
Duration duration = const Duration(seconds: 5),
EdgeInsetsGeometry? margin,
SnackBarBehavior? behavior,
ShapeBorder? shape,
DismissDirection dismissDirection = DismissDirection.down,
Color? backgroundColor,
}) {
if (scaffoldMessengerKey.currentState?.mounted == true) {
scaffoldMessengerKey.currentState?.showSnackBar(
SnackBar(
duration: duration,
shape: shape ?? _snackBarTheme?.shape,
margin: margin ?? _snackBarTheme?.insetPadding,
behavior: behavior ?? _snackBarTheme?.behavior,
dismissDirection: dismissDirection,
backgroundColor: backgroundColor ?? _snackBarTheme?.backgroundColor,
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (title != null)
Text(
title,
style: titleTextStyle ??
_snackBarTheme?.contentTextStyle
?.copyWith(fontWeight: FontWeight.bold),
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
if (body != null)
Text(
body,
style: bodyTextStyle ?? _snackBarTheme?.contentTextStyle,
maxLines: 6,
overflow: TextOverflow.ellipsis,
),
],
),
action: action ?? _buildDismissAction(),
),
);
}
}