showPlatformToast function

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

Show a toast according to the platform

If the platform is android or fuchsia (or the child is an AndroidToast), then an AndroidToast will be showed, otherwise, a StyledToast will be showed

Implementation

Future<void> showPlatformToast({
  required Widget child,
  required BuildContext context,
  Duration? duration,
  Duration? animationDuration,
  VoidCallback? onDismiss,
  AlignmentGeometry? alignment,
  EdgeInsets? padding,
  EdgeInsets? margin,
  ToastAnimationBuilder? animationBuilder,
}) {
  if ([TargetPlatform.android, TargetPlatform.fuchsia]
          .contains(defaultTargetPlatform) ||
      child is AndroidToast) {
    return showAndroidToast(
      context: context,
      child: child,
      duration: duration,
      animationDuration: animationDuration,
      alignment: alignment,
      padding: padding,
      margin: margin,
      animationBuilder: animationBuilder,
    );
  } else {
    return showStyledToast(
      child: child,
      context: context,
      duration: duration,
      animationDuration: animationDuration,
      alignment: alignment,
      contentPadding: padding,
      margin: margin,
      animationBuilder: animationBuilder,
    );
  }
}