paint method
Paints the child in the current paint context, this should only be called in BoxyDelegate.paintChildren.
Note that offset
and transform
will not transform hit tests, you may
want to use BoxyChild.position or BoxyChild.setTransform instead.
Implementers of BoxyDelegate.paintChildren should draw at BoxyDelegate.paintOffset and restore the canvas before painting a child. This is required by the framework because a child might need to insert its own compositing Layer between two other PictureLayers.
Implementation
void paint({Offset? offset, Matrix4? transform}) {
assert(
offset == null || transform == null,
'Only one of offset and transform can be provided at the same time',
);
if (_ignore) {
return;
}
assert(() {
if (_parent.debugPhase != BoxyDelegatePhase.paint) {
throw FlutterError(
'The $this boxy delegate tried to paint a child outside of the paint method.');
}
return true;
}());
if (offset == null && transform == null) {
transform = _parentData.transform;
}
if (transform != null) {
offset = MatrixUtils.getAsTranslation(transform);
if (offset == null) {
_parent.delegate.layers.transform(
transform: transform,
paint: () {
_parent.paintingContext!.paintChild(render, _parent.paintOffset!);
},
);
return;
}
}
final paintOffset = _parent.paintOffset!;
_parent.paintingContext!.paintChild(
render,
offset == null ? paintOffset : paintOffset + offset,
);
}