@@ -988,6 +988,7 @@ class RenderTable extends RenderBox {
988988 // cache the table geometry for painting purposes
989989 final List <double > _rowTops = < double > [];
990990 Iterable <double >? _columnLefts;
991+ late double _tableWidth;
991992
992993 /// Returns the position and dimensions of the box that the given
993994 /// row covers, in this render object's coordinate space (so the
@@ -1050,26 +1051,26 @@ class RenderTable extends RenderBox {
10501051 if (rows * columns == 0 ) {
10511052 // TODO(ianh): if columns is zero, this should be zero width
10521053 // TODO(ianh): if columns is not zero, this should be based on the column width specifications
1054+ _tableWidth = 0.0 ;
10531055 size = constraints.constrain (Size .zero);
10541056 return ;
10551057 }
10561058 final List <double > widths = _computeColumnWidths (constraints);
10571059 final List <double > positions = List <double >.filled (columns, 0.0 );
1058- final double tableWidth;
10591060 switch (textDirection) {
10601061 case TextDirection .rtl:
10611062 positions[columns - 1 ] = 0.0 ;
10621063 for (int x = columns - 2 ; x >= 0 ; x -= 1 )
10631064 positions[x] = positions[x+ 1 ] + widths[x+ 1 ];
10641065 _columnLefts = positions.reversed;
1065- tableWidth = positions.first + widths.first;
1066+ _tableWidth = positions.first + widths.first;
10661067 break ;
10671068 case TextDirection .ltr:
10681069 positions[0 ] = 0.0 ;
10691070 for (int x = 1 ; x < columns; x += 1 )
10701071 positions[x] = positions[x- 1 ] + widths[x- 1 ];
10711072 _columnLefts = positions;
1072- tableWidth = positions.last + widths.last;
1073+ _tableWidth = positions.last + widths.last;
10731074 break ;
10741075 }
10751076 _rowTops.clear ();
@@ -1150,7 +1151,7 @@ class RenderTable extends RenderBox {
11501151 rowTop += rowHeight;
11511152 }
11521153 _rowTops.add (rowTop);
1153- size = constraints.constrain (Size (tableWidth , rowTop));
1154+ size = constraints.constrain (Size (_tableWidth , rowTop));
11541155 assert (_rowTops.length == rows + 1 );
11551156 }
11561157
@@ -1181,7 +1182,7 @@ class RenderTable extends RenderBox {
11811182 assert (_children.length == rows * columns);
11821183 if (rows * columns == 0 ) {
11831184 if (border != null ) {
1184- final Rect borderRect = Rect .fromLTWH (offset.dx, offset.dy, size.width , 0.0 );
1185+ final Rect borderRect = Rect .fromLTWH (offset.dx, offset.dy, _tableWidth , 0.0 );
11851186 border! .paint (context.canvas, borderRect, rows: const < double > [], columns: const < double > []);
11861187 }
11871188 return ;
@@ -1216,7 +1217,7 @@ class RenderTable extends RenderBox {
12161217 // The border rect might not fill the entire height of this render object
12171218 // if the rows underflow. We always force the columns to fill the width of
12181219 // the render object, which means the columns cannot underflow.
1219- final Rect borderRect = Rect .fromLTWH (offset.dx, offset.dy, size.width , _rowTops.last);
1220+ final Rect borderRect = Rect .fromLTWH (offset.dx, offset.dy, _tableWidth , _rowTops.last);
12201221 final Iterable <double > rows = _rowTops.getRange (1 , _rowTops.length - 1 );
12211222 final Iterable <double > columns = _columnLefts! .skip (1 );
12221223 border! .paint (context.canvas, borderRect, rows: rows, columns: columns);
0 commit comments