@@ -81,6 +81,8 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
81
81
}
82
82
}
83
83
84
+ bool _overflowOccurredDuringLayout = false ;
85
+
84
86
void setupParentData (RenderBox child) {
85
87
if (child.parentData is ! FlexBoxParentData )
86
88
child.parentData = new FlexBoxParentData ();
@@ -376,16 +378,20 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
376
378
break ;
377
379
}
378
380
381
+ Size desiredSize;
379
382
switch (_direction) {
380
383
case FlexDirection .horizontal:
381
- size = constraints.constrain (new Size (mainSize, crossSize));
384
+ desiredSize = new Size (mainSize, crossSize);
385
+ size = constraints.constrain (desiredSize);
382
386
crossSize = size.height;
383
387
break ;
384
388
case FlexDirection .vertical:
389
+ desiredSize = new Size (crossSize, mainSize);
385
390
size = constraints.constrain (new Size (crossSize, mainSize));
386
391
crossSize = size.width;
387
392
break ;
388
393
}
394
+ _overflowOccurredDuringLayout = desiredSize != size;
389
395
390
396
// Position elements
391
397
double childMainPosition = leadingSpace;
@@ -433,6 +439,13 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
433
439
}
434
440
435
441
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
+ }
437
450
}
438
451
}
0 commit comments