showPlatformToast function
Future<void>
showPlatformToast({
- required Widget child,
- required BuildContext context,
- Duration? duration,
- Duration? animationDuration,
- VoidCallback? onDismiss,
- AlignmentGeometry? alignment,
- EdgeInsets? padding,
- EdgeInsets? margin,
- 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,
);
}
}