showToast function

Future<void> showToast(
  1. {required Widget child,
  2. required BuildContext context,
  3. Duration? duration,
  4. Duration? animationDuration,
  5. VoidCallback? onDismiss,
  6. AlignmentGeometry? alignment,
  7. EdgeInsets? padding,
  8. ToastAnimationBuilder? animationBuilder}
)

Show a toast.

child and context must not be null.

If child is a Toast, then all other arguments will be discarted

Implementation

Future<void> showToast({
  required Widget child,
  required BuildContext context,
  Duration? duration,
  Duration? animationDuration,
  VoidCallback? onDismiss,
  AlignmentGeometry? alignment,
  EdgeInsets? padding,
  ToastAnimationBuilder? animationBuilder,
}) async {
  if (child is Toast)
    await showToastWidget(
      toast: child,
      context: context,
    );
  else {
    await showToastWidget(
      context: context,
      toast: Toast(
        duration: duration,
        animationDuration: animationDuration,
        alignment: alignment,
        padding: padding,
        onDismiss: onDismiss,
        animationBuilder: animationBuilder,
        child: child,
      ),
    );
  }
}