@@ -32,7 +32,7 @@ export 'package:flutter/rendering.dart' show
3232@immutable
3333class TableRow {
3434 /// Creates a row in a [Table] .
35- const TableRow ({ this .key, this .decoration, this .children });
35+ const TableRow ({ this .key, this .decoration, this .children = const < Widget > [] });
3636
3737 /// An identifier for the row.
3838 final LocalKey ? key;
@@ -49,7 +49,7 @@ class TableRow {
4949 /// Children may be wrapped in [TableCell] widgets to provide per-cell
5050 /// configuration to the [Table] , but children are not required to be wrapped
5151 /// in [TableCell] widgets.
52- final List <Widget >? children;
52+ final List <Widget > children;
5353
5454 @override
5555 String toString () {
@@ -61,9 +61,7 @@ class TableRow {
6161 if (decoration != null ) {
6262 result.write ('$decoration , ' );
6363 }
64- if (children == null ) {
65- result.write ('child list is null' );
66- } else if (children! .isEmpty) {
64+ if (children.isEmpty) {
6765 result.write ('no children' );
6866 } else {
6967 result.write ('$children ' );
@@ -127,15 +125,6 @@ class Table extends RenderObjectWidget {
127125 this .defaultVerticalAlignment = TableCellVerticalAlignment .top,
128126 this .textBaseline, // NO DEFAULT: we don't know what the text's baseline should be
129127 }) : assert (defaultVerticalAlignment != TableCellVerticalAlignment .baseline || textBaseline != null , 'textBaseline is required if you specify the defaultVerticalAlignment with TableCellVerticalAlignment.baseline' ),
130- assert (() {
131- if (children.any ((TableRow row) => row.children == null )) {
132- throw FlutterError (
133- 'One of the rows of the table had null children.\n '
134- 'The children property of TableRow must not be null.' ,
135- );
136- }
137- return true ;
138- }()),
139128 assert (() {
140129 if (children.any ((TableRow row1) => row1.key != null && children.any ((TableRow row2) => row1 != row2 && row1.key == row2.key))) {
141130 throw FlutterError (
@@ -147,8 +136,8 @@ class Table extends RenderObjectWidget {
147136 }()),
148137 assert (() {
149138 if (children.isNotEmpty) {
150- final int cellCount = children.first.children! .length;
151- if (children.any ((TableRow row) => row.children! .length != cellCount)) {
139+ final int cellCount = children.first.children.length;
140+ if (children.any ((TableRow row) => row.children.length != cellCount)) {
152141 throw FlutterError (
153142 'Table contains irregular row lengths.\n '
154143 'Every TableRow in a Table must have the same number of children, so that every cell is filled. '
@@ -162,7 +151,7 @@ class Table extends RenderObjectWidget {
162151 ? children.map <Decoration ?>((TableRow row) => row.decoration).toList (growable: false )
163152 : null {
164153 assert (() {
165- final List <Widget > flatChildren = children.expand <Widget >((TableRow row) => row.children! ).toList (growable: false );
154+ final List <Widget > flatChildren = children.expand <Widget >((TableRow row) => row.children).toList (growable: false );
166155 return ! debugChildrenHaveDuplicateKeys (this , flatChildren, message:
167156 'Two or more cells in this Table contain widgets with the same key.\n '
168157 'Every widget child of every TableRow in a Table must have different keys. The cells of a Table are '
@@ -238,7 +227,7 @@ class Table extends RenderObjectWidget {
238227 RenderTable createRenderObject (BuildContext context) {
239228 assert (debugCheckHasDirectionality (context));
240229 return RenderTable (
241- columns: children.isNotEmpty ? children[0 ].children! .length : 0 ,
230+ columns: children.isNotEmpty ? children[0 ].children.length : 0 ,
242231 rows: children.length,
243232 columnWidths: columnWidths,
244233 defaultColumnWidth: defaultColumnWidth,
@@ -254,7 +243,7 @@ class Table extends RenderObjectWidget {
254243 @override
255244 void updateRenderObject (BuildContext context, RenderTable renderObject) {
256245 assert (debugCheckHasDirectionality (context));
257- assert (renderObject.columns == (children.isNotEmpty ? children[0 ].children! .length : 0 ));
246+ assert (renderObject.columns == (children.isNotEmpty ? children[0 ].children.length : 0 ));
258247 assert (renderObject.rows == children.length);
259248 renderObject
260249 ..columnWidths = columnWidths
@@ -289,7 +278,7 @@ class _TableElement extends RenderObjectElement {
289278 rowIndex += 1 ;
290279 return _TableElementRow (
291280 key: row.key,
292- children: row.children! .map <Element >((Widget child) {
281+ children: row.children.map <Element >((Widget child) {
293282 return inflateWidget (child, _TableSlot (columnIndex++ , rowIndex));
294283 }).toList (growable: false ),
295284 );
@@ -347,12 +336,12 @@ class _TableElement extends RenderObjectElement {
347336 oldChildren = const < Element > [];
348337 }
349338 final List <_TableSlot > slots = List <_TableSlot >.generate (
350- row.children! .length,
339+ row.children.length,
351340 (int columnIndex) => _TableSlot (columnIndex, rowIndex),
352341 );
353342 newChildren.add (_TableElementRow (
354343 key: row.key,
355- children: updateChildren (oldChildren, row.children! , forgottenChildren: _forgottenChildren, slots: slots),
344+ children: updateChildren (oldChildren, row.children, forgottenChildren: _forgottenChildren, slots: slots),
356345 ));
357346 }
358347 while (oldUnkeyedRows.moveNext ()) {
0 commit comments