diff --git a/packages/flutter/lib/src/rendering/table.dart b/packages/flutter/lib/src/rendering/table.dart index 53333e0911..c68dd1b7a1 100644 --- a/packages/flutter/lib/src/rendering/table.dart +++ b/packages/flutter/lib/src/rendering/table.dart @@ -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) { diff --git a/packages/flutter/test/widgets/table_test.dart b/packages/flutter/test/widgets/table_test.dart index 62d3fb7b10..26e5ab699d 100644 --- a/packages/flutter/test/widgets/table_test.dart +++ b/packages/flutter/test/widgets/table_test.dart @@ -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( + children: [ + cell, cell, cell, cell, cell, cell, + ], + ), + TableRow( + children: [ + 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(