show<T> static method

Future<T?> show<T>({
  1. required WidgetBuilder builder,
  2. SmartDialogController? controller,
  3. Alignment? alignment,
  4. bool? clickMaskDismiss,
  5. bool? usePenetrate,
  6. bool? useAnimation,
  7. SmartAnimationType? animationType,
  8. List<SmartNonAnimationType>? nonAnimationTypes,
  9. AnimationBuilder? animationBuilder,
  10. Duration? animationTime,
  11. Color? maskColor,
  12. Widget? maskWidget,
  13. bool? debounce,
  14. VoidCallback? onDismiss,
  15. VoidCallback? onMask,
  16. Duration? displayTime,
  17. String? tag,
  18. bool? backDismiss,
  19. bool? keepSingle,
  20. bool? permanent,
  21. bool? useSystem,
  22. bool? bindPage,
  23. BuildContext? bindWidget,
  24. Rect? ignoreArea,
})

custom dialog

builder:the custom dialog

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

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

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

animationType:Set the animation type, 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 and usePenetrate is true

maskWidget:highly customizable mask

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

debounce:debounce feature

onDismiss:the callback will be invoked when the dialog is closed

displayTime:Controls the display time of the dialog on the screen; the default is null, if it is null, it means that the param will not control the dialog to close; note: Using the displayTime param will disable the use of the tag param

tag:If you set a tag for the dialog, you can turn it off in a targeted manner

backDismiss:true(the back event will close the dialog but not close the page), false(the back event not close the dialog and not close page),you still can use the dismiss method to close the dialog

keepSingle:default (false), true (calling show multiple times will not generate multiple dialogs, only single dialog will be kept), false (calling show multiple times will generate multiple dialogs)

permanent: default (false), true (set the dialog as a permanent dialog), false (not set); Various security operations (return events, routing) inside the framework cannot close the permanent dialog, you need to close this kind of dialog: dismiss(force: true)

useSystem:default (false), true (using the system dialog, usePenetrate is invalid; tag, keepSingle and permanent are prohibited), false (using SmartDialog), using this param can make SmartDialog reasonably interact with the routing page and the dialog that comes with flutter

bindPage:bind the dialog to the current page, the bound page is not on the top of the stack, the dialog is automatically hidden, the bound page is placed on the top of the stack, and the dialog is automatically displayed; the bound page is closed, and the dialog bound to the page will also be removed

bindWidget:bind the dialog to a Widget, when the widget is not visible, the dialog is automatically hidden, and when the widget is visible, the dialog is automatically displayed; Applicable to PageView, TabView, etc., bind its sub-pages, and when switching pages, the dialog can also interact reasonably Note: The processing logic of bindWidget takes precedence over bindPage. When bindWidget is not null, bindPage will be automatically set to false.

ignoreArea: dialog placeholder ignores area, supports up, down, left and right areas, set area, dialog will not occupy space in this area; Example: ignoreArea: Rect.fromLTRB (0,0,0,30), there will be 30 gaps at the bottom, and neither dialog nor mask will occupy this area; Applies to: do not want the dialog to overwrite the navigation bar area such as BottomNavigationBar, NavigationRail

自定义弹窗

builder:自定义 dialog

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

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

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

animationType:设置动画类型, 具体可参照SmartAnimationType注释

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

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

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

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

animationTime:动画持续时间

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

maskWidget:可高度定制遮罩

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

debounce:防抖功能

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

displayTime:控制弹窗在屏幕上显示时间; 默认为null, 为null则代表该参数不会控制弹窗关闭; 注: 使用displayTime参数, 将禁止使用tag参数

tag:如果你给dialog设置了tag, 你可以针对性的关闭它

backDismiss:true(返回事件将关闭dialog,但是不会关闭页面), false(返回事件不会关闭loading,也不会关闭页面),你仍然可以使用dismiss方法来关闭dialog

keepSingle:默认(false),true(多次调用show并不会生成多个dialog,仅仅保持一个dialog), false(多次调用show会生成多个dialog)

permanent:默认(false),true(将该dialog设置为永久化dialog),false(不设置); 框架内部各种兜底操作(返回事件,路由)无法关闭永久化dialog, 需要关闭此类dialog可使用: dismiss(force: true)

useSystem:默认(false),true(使用系统dialog,usePenetrate功能失效; tag, keepSinglepermanent禁止使用), false(使用SmartDialog),使用该参数可使SmartDialog, 与路由页面以及flutter自带dialog合理交互

bindPage:将该dialog与当前页面绑定,绑定页面不在路由栈顶,dialog自动隐藏,绑定页面置于路由栈顶,dialog自动显示; 绑定页面被关闭,被绑定在该页面上的dialog也将被移除

bindWidget:将dialog与某个Widget绑定, 当该widget不可见时, dialog自动隐藏, 该widget可见时, dialog自动显示; 适用于PageView, TabView之类, 绑定其子页面, 切换页面时, dialog也能合理交互 注意: bindWidget处理逻辑高于bindPage, 当bindWidget不为null, bindPage将自动被设置为false

ignoreArea:dialog占位忽略区域, 支持上下左右区域, 设置的区域, dialog将不会在此区域占位; 例: ignoreArea: Rect.fromLTRB(0, 0, 0, 30), 底部会有30空隙, dialog和mask都不会占位该区域; 适用于: 不想dialog覆盖BottomNavigationBar, NavigationRail之类的导航栏区域

Implementation

static Future<T?> show<T>({
  required WidgetBuilder builder,
  SmartDialogController? controller,
  Alignment? alignment,
  bool? clickMaskDismiss,
  bool? usePenetrate,
  bool? useAnimation,
  SmartAnimationType? animationType,
  List<SmartNonAnimationType>? nonAnimationTypes,
  AnimationBuilder? animationBuilder,
  Duration? animationTime,
  Color? maskColor,
  Widget? maskWidget,
  bool? debounce,
  VoidCallback? onDismiss,
  VoidCallback? onMask,
  Duration? displayTime,
  String? tag,
  bool? backDismiss,
  bool? keepSingle,
  bool? permanent,
  bool? useSystem,
  bool? bindPage,
  BuildContext? bindWidget,
  Rect? ignoreArea,
}) {
  assert(
    (useSystem == true &&
            tag == null &&
            permanent == null &&
            keepSingle == null) ||
        (useSystem == null || useSystem == false),
    'useSystem is true; tag, keepSingle and permanent prohibit setting values',
  );

  return DialogProxy.instance.show<T>(
    widget: DialogScope(
      controller: controller,
      builder: (context) => builder(context),
    ),
    alignment: alignment ?? config.custom.alignment,
    clickMaskDismiss: clickMaskDismiss ?? config.custom.clickMaskDismiss,
    animationType: animationType ?? config.custom.animationType,
    nonAnimationTypes: nonAnimationTypes ?? config.custom.nonAnimationTypes,
    animationBuilder: animationBuilder,
    usePenetrate: usePenetrate ?? config.custom.usePenetrate,
    useAnimation: useAnimation ?? config.custom.useAnimation,
    animationTime: animationTime ?? config.custom.animationTime,
    maskColor: maskColor ?? config.custom.maskColor,
    maskWidget: maskWidget ?? config.custom.maskWidget,
    debounce: debounce ?? config.custom.debounce,
    onDismiss: onDismiss,
    onMask: onMask,
    displayTime: displayTime,
    tag: tag,
    backDismiss: backDismiss ?? config.custom.backDismiss,
    keepSingle: keepSingle ?? false,
    permanent: permanent ?? false,
    useSystem: useSystem ?? false,
    bindPage: (bindPage ?? config.custom.bindPage) && bindWidget == null,
    bindWidget: bindWidget,
    ignoreArea: ignoreArea,
  );
}