Unverified Commit c00e9798 authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

Fix _paintAvatar in chip.dart to dispose layer. (#135228)

parent a4e3f933
......@@ -2065,21 +2065,26 @@ class _RenderChip extends RenderBox with SlottedContainerRenderObjectMixin<_Chip
}
}
final LayerHandle<OpacityLayer> _childOpacityLayerHandler = LayerHandle<OpacityLayer>();
void _paintChild(PaintingContext context, Offset offset, RenderBox? child, bool? isEnabled) {
if (child == null) {
_childOpacityLayerHandler.layer = null;
return;
}
final int disabledColorAlpha = _disabledColor.alpha;
if (!enableAnimation.isCompleted) {
if (needsCompositing) {
context.pushLayer(
OpacityLayer(alpha: disabledColorAlpha),
_childOpacityLayerHandler.layer = context.pushOpacity(
offset,
disabledColorAlpha,
(PaintingContext context, Offset offset) {
context.paintChild(child, _boxParentData(child).offset + offset);
},
offset,
oldLayer: _childOpacityLayerHandler.layer,
);
} else {
_childOpacityLayerHandler.layer = null;
final Rect childRect = _boxRect(child).shift(offset);
context.canvas.saveLayer(childRect.inflate(20.0), Paint()..color = _disabledColor);
context.paintChild(child, _boxParentData(child).offset + offset);
......@@ -2092,6 +2097,7 @@ class _RenderChip extends RenderBox with SlottedContainerRenderObjectMixin<_Chip
@override
void dispose() {
_childOpacityLayerHandler.layer = null;
_avatarOpacityLayerHandler.layer = null;
super.dispose();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment