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

This commit is contained in:
Polina Cherkasova
2023-09-22 15:26:52 -07:00
committed by GitHub
parent a4e3f93367
commit c00e9798ff

View File

@@ -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();
}