WidgetMask class

A widget which paints a mask widget into a save layer and blends that layer with its child.

blendMode determines how mask and child are blended with each other. In the context of this widget mask is the src and child the dst.

This widget sizes itself to the dimensions of child and forces mask to the same size. For the purpose of hit testing mask is painted over child.

Since mask is panted into a save layer, this widget is relatively expensive. See Canvas.saveLayer for more on the performance implications of a save layer.

mask must not contain RenderObjects which need compositing because the save layer into which mask is painted cannot encompass compositing layers. RepaintBoundary is a widget, whose RenderObject needs compositing, for example.

Inheritance

Constructors

WidgetMask({Key? key, BlendMode blendMode = BlendMode.srcOver, bool childSaveLayer = false, required Widget mask, required Widget child})
Creates a widget which paints a mask widget into a save layer and blends that layer with its child.
const

Properties

blendMode BlendMode
The BlendMode to use when blending the mask save layer with child.
final
child Widget
The widget which determines the size of this widget and is painted behind the mask widget.
final
childSaveLayer bool
Whether to paint child in its own save layer.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
mask Widget
The widget which is painted over the child widget, in a save layer with BlendMode blendMode.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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.
override
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}) 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