@@ -709,6 +709,8 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
709709 addAll (children);
710710 }
711711
712+ bool _hasVisualOverflow = false ;
713+
712714 @override
713715 void setupParentData (RenderBox child) {
714716 if (child.parentData is ! StackParentData ) {
@@ -834,6 +836,8 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
834836
835837 @override
836838 void performLayout () {
839+ _hasVisualOverflow = false ;
840+
837841 if (_onstageChildCount == 0 ) {
838842 return ;
839843 }
@@ -852,7 +856,7 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
852856 child.layout (nonPositionedConstraints, parentUsesSize: true );
853857 childParentData.offset = _resolvedAlignment! .alongOffset (size - child.size as Offset );
854858 } else {
855- RenderStack .layoutPositionedChild (child, childParentData, size, _resolvedAlignment! );
859+ _hasVisualOverflow = RenderStack .layoutPositionedChild (child, childParentData, size, _resolvedAlignment! ) || _hasVisualOverflow ;
856860 }
857861
858862 assert (child.parentData == childParentData);
@@ -894,7 +898,7 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
894898
895899 @override
896900 void paint (PaintingContext context, Offset offset) {
897- if (clipBehavior != Clip .none) {
901+ if (_hasVisualOverflow && clipBehavior != Clip .none) {
898902 _clipRectLayer.layer = context.pushClipRect (
899903 needsCompositing,
900904 offset,
@@ -935,7 +939,7 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
935939 case Clip .hardEdge:
936940 case Clip .antiAlias:
937941 case Clip .antiAliasWithSaveLayer:
938- return Offset .zero & size;
942+ return _hasVisualOverflow ? Offset .zero & size : null ;
939943 }
940944 }
941945
0 commit comments