addCustomWatermark method

void addCustomWatermark(
  1. BuildContext context,
  2. Widget widget
)

添加自定义水印。将widget覆盖在所有视图的最上层

Implementation

void addCustomWatermark(BuildContext context, Widget widget) {
  if (_overlayEntry != null) {
    _overlayEntry!.remove();
  }
  OverlayState? overlayState = Overlay.of(context);
  _overlayEntry = OverlayEntry(
    builder: (context) => IgnorePointer(//忽略自定义水印的点击事件
      child: widget,
    ),
  );
  overlayState?.insert(_overlayEntry!);
}