Unverified Commit fbfaffe1 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Do not add run spacing if there are no run metrics (#16290)

* do not add run spacing if there are no run metrics
parent 38970f5f
......@@ -629,7 +629,9 @@ class RenderWrap extends RenderBox with ContainerRenderObjectMixin<RenderBox, Wr
}
if (childCount > 0) {
mainAxisExtent = math.max(mainAxisExtent, runMainAxisExtent);
crossAxisExtent += runCrossAxisExtent + runSpacing;
crossAxisExtent += runCrossAxisExtent;
if (runMetrics.isNotEmpty)
crossAxisExtent += runSpacing;
runMetrics.add(new _RunMetrics(runMainAxisExtent, runCrossAxisExtent, childCount));
}
......
......@@ -710,7 +710,7 @@ void main() {
),
),
);
expect(tester.renderObject<RenderBox>(find.byType(Wrap)).size, equals(const Size(270.0, 258.0)));
expect(tester.renderObject<RenderBox>(find.byType(Wrap)).size, equals(const Size(270.0, 250.0)));
verify(tester, <Offset>[
const Offset(0.0, 0.0),
const Offset(22.0, 0.0),
......@@ -853,17 +853,46 @@ void main() {
});
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: const <Widget>[
const SizedBox(width: 800.0, height: 0.0),
],
));
await tester.pumpWidget(
new Column(
children: <Widget>[
new Wrap(
direction: Axis.horizontal,
textDirection: TextDirection.ltr,
spacing: 10.0,
runSpacing: 10.0,
children: const <Widget>[
const SizedBox(width: 800.0, height: 10.0),
],
),
],
)
);
expect(tester.renderObject<RenderBox>(find.byType(Wrap)).size, equals(const Size(800.0, 600.0)));
expect(tester.renderObject<RenderBox>(find.byType(Wrap)).size, equals(const Size(800.0, 10.0)));
verify(tester, <Offset>[const Offset(0.0, 0.0)]);
await tester.pumpWidget(
new Column(
children: <Widget>[
new Wrap(
direction: Axis.horizontal,
textDirection: TextDirection.ltr,
spacing: 10.0,
runSpacing: 10.0,
children: const <Widget>[
const SizedBox(width: 800.0, height: 10.0),
const SizedBox(width: 800.0, height: 10.0),
],
),
],
)
);
expect(tester.renderObject<RenderBox>(find.byType(Wrap)).size, equals(const Size(800.0, 30.0)));
verify(tester, <Offset>[
const Offset(0.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