mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Do not add run spacing if there are no run metrics (#16290)
* do not add run spacing if there are no run metrics
This commit is contained in:
parent
38970f5f75
commit
fbfaffe1db
@ -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),
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user