@@ -598,9 +598,13 @@ class RenderHtmlFlex extends RenderBox
598598 };
599599 }
600600
601+ static final _fwfhFlexByRenderBox = Expando <int >();
602+
601603 static int _getFlex (RenderBox child) {
602604 final FlexParentData childParentData = child.parentData! as FlexParentData ;
603- return childParentData.flex ?? 0 ;
605+ final fwfhFlex = _fwfhFlexByRenderBox[child] ?? 0 ;
606+ final fwfhFlexOrNull = fwfhFlex > 0 ? fwfhFlex : null ;
607+ return fwfhFlexOrNull ?? childParentData.flex ?? 0 ;
604608 }
605609
606610 static FlexFit _getFit (RenderBox child) {
@@ -967,15 +971,25 @@ class RenderHtmlFlex extends RenderBox
967971 size: layoutChild (child, nonFlexChildConstraints),
968972 direction: direction,
969973 );
970- accumulatedSize += childSize;
971-
972- final double ? baselineOffset = textBaseline == null
973- ? null
974- : getBaseline (child, nonFlexChildConstraints, textBaseline);
975- accumulatedAscentDescent += _AscentDescent (
976- baselineOffset: baselineOffset,
977- crossSize: childSize.crossAxisExtent,
978- );
974+
975+ if (canFlex && childSize.mainAxisExtent > maxMainSize) {
976+ // e.g. child is wider than available width -> flex it
977+ final newFlex = (childSize.mainAxisExtent - maxMainSize).toInt ();
978+ _fwfhFlexByRenderBox[child] = newFlex;
979+ totalFlex += newFlex;
980+ firstFlexChild ?? = child;
981+ } else {
982+ _fwfhFlexByRenderBox[child] = - 1 ;
983+ accumulatedSize += childSize;
984+
985+ final double ? baselineOffset = textBaseline == null
986+ ? null
987+ : getBaseline (child, nonFlexChildConstraints, textBaseline);
988+ accumulatedAscentDescent += _AscentDescent (
989+ baselineOffset: baselineOffset,
990+ crossSize: childSize.crossAxisExtent,
991+ );
992+ }
979993 }
980994 }
981995
0 commit comments