snackbar static method

dynamic snackbar(
  1. BuildContext context,
  2. String message, {
  3. bool? showCloseIcon,
  4. int? seconds,
  5. TextStyle? textStyle,
  6. int maxLines = 2,
  7. TextAlign textAlign = TextAlign.center,
  8. Color? backgroundColor,
  9. Color? closeIconColor,
})

Show a snackbar

Implementation

static snackbar(
  BuildContext context,
  String message, {
  bool? showCloseIcon,
  int? seconds,
  TextStyle? textStyle,
  int maxLines = 2,
  TextAlign textAlign = TextAlign.center,
  Color? backgroundColor,
  Color? closeIconColor,
}) {
  ScaffoldMessenger.of(context).showSnackBar(
    SnackBar(
      behavior: SnackBarBehavior.floating,
      backgroundColor: backgroundColor,
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
      elevation: 0,
      content: Text(
        message,
        textAlign: textAlign,
        maxLines: maxLines,
        style: textStyle,
      ),
      showCloseIcon: showCloseIcon ?? true,
      closeIconColor: closeIconColor,
      duration: Duration(seconds: seconds ?? 4),
    ),
  );
}