prevent _computeColumnWidths from getting stuck due to double precision (#27112)
This commit is contained in:
@@ -916,7 +916,10 @@ class RenderTable extends RenderBox {
|
||||
// columns shrinking them proportionally until we have no
|
||||
// available columns, then do the same to the non-flexible ones.
|
||||
int availableColumns = columns;
|
||||
while (deficit > 0.0 && totalFlex > 0.0) {
|
||||
// Handle double precision errors which causes this loop to become
|
||||
// stuck in certain configurations.
|
||||
const double minimumDeficit = 0.00000001;
|
||||
while (deficit > minimumDeficit && totalFlex > minimumDeficit) {
|
||||
double newTotalFlex = 0.0;
|
||||
for (int x = 0; x < columns; x += 1) {
|
||||
if (flexes[x] != null) {
|
||||
|
||||
@@ -297,6 +297,31 @@ void main() {
|
||||
expect(boxG1, isNot(equals(boxG2)));
|
||||
});
|
||||
|
||||
testWidgets('Really small deficit double precision error', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/27083
|
||||
const SizedBox cell = SizedBox(width: 16, height: 16);
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Table(
|
||||
children: const <TableRow>[
|
||||
TableRow(
|
||||
children: <Widget>[
|
||||
cell, cell, cell, cell, cell, cell,
|
||||
],
|
||||
),
|
||||
TableRow(
|
||||
children: <Widget>[
|
||||
cell, cell, cell, cell, cell, cell,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
// If the above bug is present this test will never terminate.
|
||||
});
|
||||
|
||||
testWidgets('Table widget - repump test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
|
||||
Reference in New Issue
Block a user