Unverified Commit 27df2885 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

RenderWrap.performLayout should take spacing into consideration (#15256)

* RenderWrap.performLayout takes should take spacing into consideration when deciding to move to next row/axis

* fix spacing in text

* remove dart:developer import

* remove extra line
parent c2261a3a
......@@ -608,7 +608,7 @@ class RenderWrap extends RenderBox with ContainerRenderObjectMixin<RenderBox, Wr
child.layout(childConstraints, parentUsesSize: true);
final double childMainAxisExtent = _getMainAxisExtent(child);
final double childCrossAxisExtent = _getCrossAxisExtent(child);
if (runMainAxisExtent + childMainAxisExtent > mainAxisLimit) {
if (runMainAxisExtent + childMainAxisExtent + spacing > mainAxisLimit) {
assert(childCount > 0);
mainAxisExtent = math.max(mainAxisExtent, runMainAxisExtent);
crossAxisExtent += runCrossAxisExtent;
......
......@@ -828,4 +828,27 @@ void main() {
expect(tester.renderObject<RenderBox>(find.byType(Baseline)).size,
within<Size>(from: const Size(100.0, 200.0), distance: 0.001));
});
testWidgets('Spacing with slight overflow', (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: 200.0, height: 10.0),
const SizedBox(width: 200.0, height: 10.0),
const SizedBox(width: 200.0, height: 10.0),
const SizedBox(width: 171.0, height: 10.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),
const Offset(210.0, 0.0),
const Offset(420.0, 0.0),
const Offset(0.0, 20.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