showAttach static method

Future<void> showAttach({
  1. required BuildContext? targetContext,
  2. required Widget widget,
  3. Offset? target,
  4. AlignmentGeometry? alignmentTemp,
  5. bool? clickBgDismissTemp,
  6. bool? isLoadingTemp,
  7. bool? isPenetrateTemp,
  8. bool? isUseAnimationTemp,
  9. Duration? animationDurationTemp,
  10. Color? maskColorTemp,
  11. Widget? maskWidgetTemp,
  12. bool? debounceTemp,
  13. Positioned? highlight,
  14. HighlightBuilder? highlightBuilder,
  15. VoidCallback? onDismiss,
  16. String? tag,
  17. bool? backDismiss,
  18. bool? keepSingle,
  19. bool? useSystem,
})

custom dialog for specific locations:param with a suffix of 'temp', indicating that such params can be set to default values in Config

targetContext:BuildContext with target widget

widget:custom widget

target:target offset,when the target is set to value, the targetContext param will be invalid

alignmentTemp:control the location of the dialog

clickBgDismissTemp:true(the dialog will be closed after click background),false(not close)

isLoadingTemp:true(use the opacity animation),false(use the scale transition animation)

isPenetrateTemp:true(the click event will penetrate background),false(not penetration)

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

animationDurationTemp:animation duration

maskColorTemp:the color of the mask,it is invalid if maskWidgetTemp set the value and isPenetrateTemp is true

maskWidgetTemp:highly customizable mask

debounceTemp:debounce feature

highlight:highlight feature, dissolve the mask of a specific area

highlightBuilder:the function is the same as highlight, it may be a little troublesome to use, but you can quickly get the target widget info(Coordinates and size); Note: If highlightBuilder is used, highlight will be invalid

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

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

backDismiss:default(true),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 showAttach multiple times will not generate multiple dialogs, only single dialog will be kept), false (calling showAttach multiple times will generate multiple dialogs)

useSystem: default (false), true (using the system dialog, isPenetrateTemp is invalid, tag and keepSingle are prohibited), false (using SmartDialog), this param can completely solve the page jump scene on the dialog


提供自定义特定位置弹窗:以 'temp' 后缀的参数,表示此类参数都可在Config中设置默认值

targetContext:伴随位置widget的BuildContext

widget:自定义 widget

target:target offset,当target被设置数据,targetContext参数将失效

alignmentTemp:控制弹窗的位置

clickBgDismissTemp:true(点击半透明的暗色背景后,将关闭loading),false(不关闭)

isLoadingTemp:true(使用透明动画),false(使用尺寸缩放动画)

isPenetrateTemp:true(点击事件将穿透背景),false(不穿透)

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

animationDurationTemp:动画持续时间

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

maskWidgetTemp:可高度定制遮罩

debounceTemp:防抖功能(debounce)

highlight:高亮功能,溶解特定区域的遮罩

highlightBuilder:功能和highlight一致,使用上可能麻烦一点,但是可以快速获取目标widget信息(坐标和大小); 注:使用了highlightBuilderhighlight将失效

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

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

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

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

useSystem:默认(false),true(使用系统dialog,isPenetrateTemp功能失效,tagkeepSingle禁止使用), false(使用SmartDialog),此参数可彻底解决在弹窗上跳转页面问题

Implementation

static Future<void> showAttach({
  required BuildContext? targetContext,
  required Widget widget,
  Offset? target,
  AlignmentGeometry? alignmentTemp,
  bool? clickBgDismissTemp,
  bool? isLoadingTemp,
  bool? isPenetrateTemp,
  bool? isUseAnimationTemp,
  Duration? animationDurationTemp,
  Color? maskColorTemp,
  Widget? maskWidgetTemp,
  bool? debounceTemp,
  Positioned? highlight,
  HighlightBuilder? highlightBuilder,
  VoidCallback? onDismiss,
  String? tag,
  bool? backDismiss,
  bool? keepSingle,
  bool? useSystem,
}) {
  assert(
    targetContext != null || target != null,
    'targetContext and target, cannot both be null',
  );
  assert(
    (useSystem == true && keepSingle == null && tag == null) ||
        (useSystem == null || useSystem == false),
    'useSystem is true, keepSingle and tag prohibit setting values',
  );
  assert(
    keepSingle == null || keepSingle == false || tag == null,
    'keepSingle is true, tag prohibit setting values',
  );

  return DialogProxy.instance.showAttach(
    targetContext: targetContext,
    target: target,
    widget: widget,
    alignment: alignmentTemp ?? Alignment.bottomCenter,
    clickBgDismiss: clickBgDismissTemp ?? config.clickBgDismiss,
    isLoading: isLoadingTemp ?? false,
    isPenetrate: isPenetrateTemp ?? config.isPenetrate,
    isUseAnimation: isUseAnimationTemp ?? config.isUseAnimation,
    animationDuration: animationDurationTemp ?? config.animationDuration,
    maskColor: maskColorTemp ?? config.maskColor,
    maskWidget: maskWidgetTemp ?? config.maskWidget,
    debounce: debounceTemp ?? config.debounce,
    highlight: highlight ?? Positioned(child: Container()),
    highlightBuilder: highlightBuilder,
    onDismiss: onDismiss,
    tag: tag,
    backDismiss: backDismiss ?? true,
    keepSingle: keepSingle ?? false,
    useSystem: useSystem ?? false,
  );
}