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
This commit is contained in:
@@ -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)
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user