@@ -81,6 +81,8 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
8181 }
8282 }
8383
84+ bool _overflowOccurredDuringLayout = false ;
85+
8486 void setupParentData (RenderBox child) {
8587 if (child.parentData is ! FlexBoxParentData )
8688 child.parentData = new FlexBoxParentData ();
@@ -376,16 +378,20 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
376378 break ;
377379 }
378380
381+ Size desiredSize;
379382 switch (_direction) {
380383 case FlexDirection .horizontal:
381- size = constraints.constrain (new Size (mainSize, crossSize));
384+ desiredSize = new Size (mainSize, crossSize);
385+ size = constraints.constrain (desiredSize);
382386 crossSize = size.height;
383387 break ;
384388 case FlexDirection .vertical:
389+ desiredSize = new Size (crossSize, mainSize);
385390 size = constraints.constrain (new Size (crossSize, mainSize));
386391 crossSize = size.width;
387392 break ;
388393 }
394+ _overflowOccurredDuringLayout = desiredSize != size;
389395
390396 // Position elements
391397 double childMainPosition = leadingSpace;
@@ -433,6 +439,13 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
433439 }
434440
435441 void paint (PaintingCanvas canvas, Offset offset) {
436- defaultPaint (canvas, offset);
442+ if (_overflowOccurredDuringLayout) {
443+ canvas.save ();
444+ canvas.clipRect (offset & size);
445+ defaultPaint (canvas, offset);
446+ canvas.restore ();
447+ } else {
448+ defaultPaint (canvas, offset);
449+ }
437450 }
438451}
0 commit comments