showText method

void showText(
  1. String text, {
  2. Color? textColor,
  3. int textLines = 3,
  4. double fontSize = 16,
  5. FontWeight fontWeight = FontWeight.normal,
  6. TextAlign textAlign = TextAlign.center,
  7. Color? backgroundColor,
  8. Duration? duration,
  9. SnackBarAction? action,
  10. Animation<double>? animation,
  11. SnackBarBehavior? behavior,
  12. Key? key,
  13. double? elevation,
  14. double? width,
  15. EdgeInsetsGeometry? margin,
  16. EdgeInsetsGeometry? padding,
  17. dynamic onVisibile()?,
  18. ShapeBorder? shape,
})

Shows default SnackBar with some customizations

Implementation

void showText(
  String text, {
  Color? textColor,
  int textLines = 3,
  double fontSize = 16,
  FontWeight fontWeight = FontWeight.normal,
  TextAlign textAlign = TextAlign.center,
  Color? backgroundColor,
  Duration? duration,
  SnackBarAction? action,
  Animation<double>? animation,
  SnackBarBehavior? behavior,
  Key? key,
  double? elevation,
  double? width,
  EdgeInsetsGeometry? margin,
  EdgeInsetsGeometry? padding,
  Function()? onVisibile,
  ShapeBorder? shape,
}) {
  var _snackBar = SnackBar(
    content: TextPlus(
      text,
      color: textColor,
      maxLines: textLines,
      textOverflow: TextOverflow.ellipsis,
      fontSize: fontSize,
      fontWeight: fontWeight,
      textAlign: textAlign,
    ),
    backgroundColor: backgroundColor,
    duration: duration ?? Duration(seconds: 3),
    action: action,
    animation: animation,
    behavior: behavior,
    elevation: elevation,
    key: key,
    margin: margin,
    onVisible: onVisibile,
    padding: padding,
    shape: shape,
    width: width,
  );
  hideCurrentSnackBar();
  rootScaffoldMessengerKey.currentState!.showSnackBar(_snackBar);
}