WatermarkComponent class

水印组件:一层透明覆盖层,在其上以指定角度平铺绘制文字。

  • 默认不拦截手势(内部包裹了 IgnorePointer)。
  • 适合放在 Stack 的顶部,例如: Positioned.fill(child: WatermarkComponent(text: 'xxx'))
Inheritance

Constructors

WatermarkComponent({Key? key, String? text, List<String>? texts, TextStyle? textStyle, Color color = Colors.black, double opacity = 0.08, double rotation = -20 * math.pi / 180, double horizontalSpacing = 120, double verticalSpacing = 80, int maxPaintCount = 800, Offset textOffset = Offset.zero, bool enabled = true, TextDirection? textDirection, bool computeInBackground = true})
const

Properties

color Color
水印颜色(默认取 Colors.black)。
final
computeInBackground bool
是否将“网格点位计算”放到后台 isolate 执行。
final
enabled bool
是否启用(禁用时渲染空占位)。
final
hashCode int
The hash code for this object.
no setterinherited
horizontalSpacing double
水平间距(像素),决定水印密度。
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxPaintCount int
最大绘制数量(用于性能兜底,避免过密导致卡顿/ANR)。
final
opacity double
透明度(0~1)。
final
rotation double
旋转角度(弧度),默认 -20°。
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
text String?
单条水印文本。
final
textDirection TextDirection?
文字方向(默认从 Directionality 读取)。
final
textOffset Offset
每个水印块内文字的额外偏移(像素)。
final
texts List<String>?
多条水印文本,会在平铺时循环使用。
final
textStyle TextStyle?
文字样式(会与 color/opacity 一起生效)。
final
verticalSpacing double
垂直间距(像素),决定水印密度。
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<WatermarkComponent>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited