showSnackBar method

void showSnackBar({
  1. required String message,
  2. Duration duration = const Duration(seconds: 3),
  3. SnackBarAction? action,
  4. Color? backgroundColor,
  5. double? elevation,
  6. EdgeInsetsGeometry? margin,
  7. EdgeInsetsGeometry? padding,
  8. ShapeBorder? shape,
  9. bool isDismissible = true,
  10. bool showIcon = false,
  11. IconData? icon,
  12. Color? iconColor,
  13. double? iconSize,
  14. TextStyle? textStyle,
  15. SnackBarBehavior behavior = SnackBarBehavior.floating,
  16. DismissDirection dismissDirection = DismissDirection.horizontal,
  17. double? actionOverflowThreshold,
  18. void onVisible()?,
})

Implementation

void showSnackBar({
  required String message,
  Duration duration = const Duration(seconds: 3),
  SnackBarAction? action,
  Color? backgroundColor,
  double? elevation,
  EdgeInsetsGeometry? margin,
  EdgeInsetsGeometry? padding,
  ShapeBorder? shape,
  bool isDismissible = true,
  bool showIcon = false,
  IconData? icon,
  Color? iconColor,
  double? iconSize,
  TextStyle? textStyle,
  SnackBarBehavior behavior = SnackBarBehavior.floating,
  DismissDirection dismissDirection = DismissDirection.horizontal,
  double? actionOverflowThreshold,
  void Function()? onVisible,
}) {
  ScaffoldMessenger.of(this).showSnackBar(
    SnackBar(
      content: Row(
        children: [
          if (showIcon) Icon(icon, color: iconColor, size: iconSize),
          const SizedBox(width: 10),
          Expanded(
            child: Text(
              message,
              style: textStyle,
            ),
          ),
        ],
      ),
      duration: duration,
      action: action,
      backgroundColor: backgroundColor,
      elevation: elevation,
      margin: margin,
      padding: padding,
      shape: shape,
      behavior: behavior,
      onVisible: onVisible,
      dismissDirection: dismissDirection,
      actionOverflowThreshold: actionOverflowThreshold,
    ),
  );
}