addWatermark method

void addWatermark(
  1. BuildContext context,
  2. String watermark, {
  3. int rowCount = 3,
  4. int columnCount = 10,
  5. TextStyle? textStyle,
})

添加默认水印

watermark 水印文案 rowCount 水印文案每行显示的个数 columnCount 水印文案每列显示的个数 textStyle 水印文案的样式

Implementation

void addWatermark(BuildContext context, String watermark,
    {int rowCount = 3, int columnCount = 10, TextStyle? textStyle}) async {
  if (_overlayEntry != null) {
    _overlayEntry!.remove();
  }
  OverlayState? overlayState = Overlay.of(context);
  _overlayEntry = OverlayEntry(
      builder: (context) => DisableScreenshotsWatarmark(
            rowCount: rowCount,
            columnCount: columnCount,
            text: watermark,
            textStyle: textStyle ??
                const TextStyle(
                    color: Color(0x08000000),
                    fontSize: 18,
                    decoration: TextDecoration.none),
          ));
  overlayState?.insert(_overlayEntry!);
}