showToast static method

Future<void> showToast(
  1. String msg, {
  2. SmartDialogController? controller,
  3. Duration? displayTime,
  4. Alignment? alignment,
  5. bool? clickMaskDismiss,
  6. SmartAnimationType? animationType,
  7. List<SmartNonAnimationType>? nonAnimationTypes,
  8. AnimationBuilder? animationBuilder,
  9. bool? usePenetrate,
  10. bool? useAnimation,
  11. Duration? animationTime,
  12. Color? maskColor,
  13. Widget? maskWidget,
  14. VoidCallback? onDismiss,
  15. VoidCallback? onMask,
  16. bool? consumeEvent,
  17. bool? debounce,
  18. SmartToastType? displayType,
  19. WidgetBuilder? builder,
})

toast message

msg:msg presented to users (Use the builder param to customize the toast, this param will be invalid)

controller:this controller can be used to refresh the layout of the custom toast

displayTime:toast display time on the screen

alignment:control the location of the dialog, For details, please refer to the description of alignment parameters in SmartConfigToast

clickMaskDismiss:true(toast will be closed after click mask),false(not close)

animationType:For details, please refer to the SmartAnimationType comment

nonAnimationTypes:For different scenes, the pop-up animation can be dynamically closed. For details, please refer to SmartNonAnimationType

animationBuilder:Support highly custom animation, please refer to AnimationBuilder description for details

usePenetrate:true(the click event will penetrate mask), false(not penetration)

useAnimation:true(use the animation),false(not use)

animationTime:animation duration

maskColor:the color of the mask,it is invalid if maskWidget set the value

maskWidget:highly customizable mask

onDismiss:This callback will be triggered when the dialog is closed

onMask:This callback will be triggered when the mask is clicked

consumeEvent:true (toast will consume touch events), false (toast no longer consumes events, touch events can penetrate toast)

debounce:debounce feature

displayType:provider multiple display logic, please refer to SmartToastType comment for detailed description

builder:the custom toast


toast消息

msg:呈现给用户的信息(使用builder参数自定义toast,该参数将失效)

controller:可使用该控制器来刷新自定义的toast的布局

displayTime:toast在屏幕上的显示时间

alignment:控制弹窗的位置, 详细请参照SmartConfigToast中alignment参数说明

clickMaskDismiss:true(点击遮罩后,将关闭toast),false(不关闭)

animationType:具体可参照SmartAnimationType注释

nonAnimationTypes:对于不同的场景, 可动态关闭弹窗动画, 具体请参照SmartNonAnimationType

animationBuilder:支持高度自定义动画, 具体可参照AnimationBuilder说明

usePenetrate:true(点击事件将穿透遮罩),false(不穿透)

useAnimation:true(使用动画),false(不使用)

animationTime:动画持续时间

maskColor:遮罩颜色,如果给maskWidget设置了值,该参数将会失效

maskWidget:可高度定制遮罩

onDismiss:在dialog被关闭的时候,该回调将会被触发

onMask:点击遮罩时,该回调将会被触发

consumeEvent:true(toast会消耗触摸事件),false(toast不再消耗事件,触摸事件能穿透toast)

debounce:防抖功能

displayType:提供多种显示逻辑,详细描述请查看 SmartToastType 注释

builder:自定义toast

Implementation

static Future<void> showToast(
  String msg, {
  SmartDialogController? controller,
  Duration? displayTime,
  Alignment? alignment,
  bool? clickMaskDismiss,
  SmartAnimationType? animationType,
  List<SmartNonAnimationType>? nonAnimationTypes,
  AnimationBuilder? animationBuilder,
  bool? usePenetrate,
  bool? useAnimation,
  Duration? animationTime,
  Color? maskColor,
  Widget? maskWidget,
  VoidCallback? onDismiss,
  VoidCallback? onMask,
  bool? consumeEvent,
  bool? debounce,
  SmartToastType? displayType,
  WidgetBuilder? builder,
}) async {
  return DialogProxy.instance.showToast(
    widget: DialogScope(
      controller: controller,
      builder: (context) {
        return builder != null
            ? builder(context)
            : DialogProxy.instance.toastBuilder(msg);
      },
    ),
    displayTime: displayTime ?? config.toast.displayTime,
    alignment: alignment ?? config.toast.alignment,
    clickMaskDismiss: clickMaskDismiss ?? config.toast.clickMaskDismiss,
    animationType: animationType ?? config.toast.animationType,
    nonAnimationTypes: nonAnimationTypes ?? config.toast.nonAnimationTypes,
    animationBuilder: animationBuilder,
    usePenetrate: usePenetrate ?? config.toast.usePenetrate,
    useAnimation: useAnimation ?? config.toast.useAnimation,
    animationTime: animationTime ?? config.toast.animationTime,
    maskColor: maskColor ?? config.toast.maskColor,
    maskWidget: maskWidget ?? config.toast.maskWidget,
    onDismiss: onDismiss,
    onMask: onMask,
    debounce: debounce ?? config.toast.debounce,
    displayType: displayType ?? config.toast.displayType,
    consumeEvent: consumeEvent ?? config.toast.consumeEvent,
  );
}