showToast function

ToastFuture showToast(
  1. String msg, {
  2. BuildContext? context,
  3. BuildContextPredicate buildContextPredicate = _defaultContextPredicate,
  4. Duration? duration,
  5. ToastPosition? position,
  6. Color? backgroundColor,
  7. double? radius,
  8. VoidCallback? onDismiss,
  9. bool? dismissOtherToast,
  10. OKToastAnimationBuilder? animationBuilder,
  11. Duration? animationDuration,
  12. Curve? animationCurve,
  13. BoxConstraints? constraints,
  14. EdgeInsetsGeometry? margin = const EdgeInsets.all(50),
  15. TextDirection? textDirection,
  16. EdgeInsetsGeometry? textPadding,
  17. TextAlign? textAlign,
  18. TextStyle? textStyle,
  19. int? textMaxLines,
  20. TextOverflow? textOverflow,
})

Show toast with msg,

Implementation

ToastFuture showToast(
  String msg, {
  BuildContext? context,
  BuildContextPredicate buildContextPredicate = _defaultContextPredicate,
  Duration? duration,
  ToastPosition? position,
  Color? backgroundColor,
  double? radius,
  VoidCallback? onDismiss,
  bool? dismissOtherToast,
  OKToastAnimationBuilder? animationBuilder,
  Duration? animationDuration,
  Curve? animationCurve,
  BoxConstraints? constraints,
  EdgeInsetsGeometry? margin = const EdgeInsets.all(50),
  TextDirection? textDirection,
  EdgeInsetsGeometry? textPadding,
  TextAlign? textAlign,
  TextStyle? textStyle,
  int? textMaxLines,
  TextOverflow? textOverflow,
}) {
  if (context == null) {
    _throwIfNoContext(_contextMap.values, 'showToast');
  }
  context ??= buildContextPredicate(_contextMap.values);

  final ToastTheme theme = ToastTheme.of(context);
  position ??= theme.position;
  backgroundColor ??= theme.backgroundColor;
  radius ??= theme.radius;
  textDirection ??= theme.textDirection;
  textPadding ??= theme.textPadding;
  textAlign ??= theme.textAlign;
  textStyle ??= theme.textStyle;
  textMaxLines ??= theme.textMaxLines;
  textOverflow ??= theme.textOverflow;

  final Widget widget = Container(
    constraints: constraints,
    margin: margin,
    padding: textPadding,
    decoration: BoxDecoration(
      borderRadius: BorderRadius.circular(radius),
      color: backgroundColor,
    ),
    child: ClipRect(
      child: Text(
        msg,
        style: textStyle,
        textAlign: textAlign,
        maxLines: textMaxLines,
        overflow: textOverflow,
      ),
    ),
  );

  return showToastWidget(
    widget,
    context: context,
    buildContextPredicate: buildContextPredicate,
    duration: duration,
    onDismiss: onDismiss,
    position: position,
    dismissOtherToast: dismissOtherToast,
    textDirection: textDirection,
    animationBuilder: animationBuilder,
    animationDuration: animationDuration,
    animationCurve: animationCurve,
  );
}