showInAppNotification static method

void showInAppNotification({
  1. String? title,
  2. String? body,
  3. SnackBarAction? action,
  4. TextStyle? titleTextStyle,
  5. TextStyle? bodyTextStyle,
  6. Duration duration = const Duration(seconds: 5),
  7. EdgeInsetsGeometry? margin,
  8. SnackBarBehavior? behavior,
  9. ShapeBorder? shape,
  10. DismissDirection dismissDirection = DismissDirection.down,
  11. 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(),
      ),
    );
  }
}