showTextToast function

Future<void> showTextToast(
  1. {required String text,
  2. required BuildContext context,
  3. TextStyle? style,
  4. TextOverflow? overflow,
  5. TextAlign textAlign = TextAlign.center,
  6. TextDirection? textDirection,
  7. StrutStyle? strutStyle,
  8. double? textScaleFactor,
  9. Duration? duration,
  10. Duration? animationDuration,
  11. VoidCallback? onDismiss,
  12. AlignmentGeometry? alignment,
  13. EdgeInsets? padding,
  14. EdgeInsets? margin,
  15. ToastAnimationBuilder? animationBuilder,
  16. bool usePlatform = false}
)

Show a text toast. The toast is defined according to the platform. See showPlatformToast.

text and context must not be null.

Implementation

Future<void> showTextToast({
  required String text,
  required BuildContext context,
  TextStyle? style,
  TextOverflow? overflow,
  TextAlign textAlign = TextAlign.center,
  TextDirection? textDirection,
  StrutStyle? strutStyle,
  double? textScaleFactor,
  Duration? duration,
  Duration? animationDuration,
  VoidCallback? onDismiss,
  AlignmentGeometry? alignment,
  EdgeInsets? padding,
  EdgeInsets? margin,
  ToastAnimationBuilder? animationBuilder,
  bool usePlatform = false,
}) {
  final textWidget = Text(
    text,
    style: style,
    overflow: overflow,
    softWrap: true,
    textAlign: textAlign,
    textDirection: textDirection,
    strutStyle: strutStyle,
    textScaleFactor: textScaleFactor,
  );
  if (usePlatform)
    return showPlatformToast(
      child: textWidget,
      context: context,
      duration: duration,
      animationDuration: animationDuration,
      alignment: alignment,
      padding: padding,
      margin: margin,
      animationBuilder: animationBuilder,
    );
  else
    return showStyledToast(
      child: textWidget,
      context: context,
      duration: duration,
      animationDuration: animationDuration,
      alignment: alignment,
      margin: margin,
      animationBuilder: animationBuilder,
    );
}