Unverified Commit 6f5bcb97 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Do not add spacing to the first child's width in RenderWrap line wrapping (#15272)

The first child fits on the line if the line can accomodate its width.
After the first child the line needs room for the child's width plus spacing.
parent d996ab92
...@@ -608,8 +608,7 @@ class RenderWrap extends RenderBox with ContainerRenderObjectMixin<RenderBox, Wr ...@@ -608,8 +608,7 @@ class RenderWrap extends RenderBox with ContainerRenderObjectMixin<RenderBox, Wr
child.layout(childConstraints, parentUsesSize: true); child.layout(childConstraints, parentUsesSize: true);
final double childMainAxisExtent = _getMainAxisExtent(child); final double childMainAxisExtent = _getMainAxisExtent(child);
final double childCrossAxisExtent = _getCrossAxisExtent(child); final double childCrossAxisExtent = _getCrossAxisExtent(child);
if (runMainAxisExtent + childMainAxisExtent + spacing > mainAxisLimit) { if (childCount > 0 && runMainAxisExtent + spacing + childMainAxisExtent > mainAxisLimit) {
assert(childCount > 0);
mainAxisExtent = math.max(mainAxisExtent, runMainAxisExtent); mainAxisExtent = math.max(mainAxisExtent, runMainAxisExtent);
crossAxisExtent += runCrossAxisExtent; crossAxisExtent += runCrossAxisExtent;
if (runMetrics.isNotEmpty) if (runMetrics.isNotEmpty)
......
...@@ -851,4 +851,19 @@ void main() { ...@@ -851,4 +851,19 @@ void main() {
const Offset(0.0, 20.0) const Offset(0.0, 20.0)
]); ]);
}); });
testWidgets('Object exactly matches container width', (WidgetTester tester) async {
await tester.pumpWidget(new Wrap(
direction: Axis.horizontal,
textDirection: TextDirection.ltr,
spacing: 10.0,
runSpacing: 10.0,
children: <Widget>[
const SizedBox(width: 800.0, height: 0.0),
],
));
expect(tester.renderObject<RenderBox>(find.byType(Wrap)).size, equals(const Size(800.0, 600.0)));
verify(tester, <Offset>[const Offset(0.0, 0.0)]);
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment