Fixed Table flex column layout error #30437 (#30470)

RenderTable._computeColumnWidths() had a logic error that caused flex columns to be collapsed to their minimum widths in certain situations dependent on the layout width constraint and the number of flex columns.
This commit is contained in:
champeauxr 2019-04-10 21:53:27 -04:00 committed by Dan Field
parent 054e8870eb
commit a5dd074b0d
2 changed files with 15 additions and 2 deletions

View File

@ -958,8 +958,8 @@ class RenderTable extends RenderBox {
deficit -= widths[x] - minWidths[x];
widths[x] = minWidths[x];
} else {
deficit -= availableDelta;
widths[x] -= availableDelta;
deficit -= delta;
widths[x] -= delta;
newAvailableColumns += 1;
}
}

View File

@ -47,6 +47,19 @@ void main() {
expect(table.size, equals(const Size(0.0, 0.0)));
});
test('Table control test: constrained flex columns', () {
final RenderTable table = RenderTable(textDirection: TextDirection.ltr);
final List<RenderBox> children = List<RenderBox>.generate(6, (_) => RenderPositionedBox());
table.setFlatChildren(6, children);
layout(table, constraints: const BoxConstraints.tightFor(width: 100.0));
const double expectedWidth = 100.0 / 6;
for (RenderBox child in children) {
expect(child.size.width, moreOrLessEquals(expectedWidth));
}
});
test('Table test: combinations', () {
RenderTable table;
layout(RenderPositionedBox(child: table = RenderTable(