@@ -32,7 +32,7 @@ export 'package:flutter/rendering.dart' show
32
32
@immutable
33
33
class TableRow {
34
34
/// 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 > [] });
36
36
37
37
/// An identifier for the row.
38
38
final LocalKey ? key;
@@ -49,7 +49,7 @@ class TableRow {
49
49
/// Children may be wrapped in [TableCell] widgets to provide per-cell
50
50
/// configuration to the [Table] , but children are not required to be wrapped
51
51
/// in [TableCell] widgets.
52
- final List <Widget >? children;
52
+ final List <Widget > children;
53
53
54
54
@override
55
55
String toString () {
@@ -61,9 +61,7 @@ class TableRow {
61
61
if (decoration != null ) {
62
62
result.write ('$decoration , ' );
63
63
}
64
- if (children == null ) {
65
- result.write ('child list is null' );
66
- } else if (children! .isEmpty) {
64
+ if (children.isEmpty) {
67
65
result.write ('no children' );
68
66
} else {
69
67
result.write ('$children ' );
@@ -127,15 +125,6 @@ class Table extends RenderObjectWidget {
127
125
this .defaultVerticalAlignment = TableCellVerticalAlignment .top,
128
126
this .textBaseline, // NO DEFAULT: we don't know what the text's baseline should be
129
127
}) : 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
- }()),
139
128
assert (() {
140
129
if (children.any ((TableRow row1) => row1.key != null && children.any ((TableRow row2) => row1 != row2 && row1.key == row2.key))) {
141
130
throw FlutterError (
@@ -147,8 +136,8 @@ class Table extends RenderObjectWidget {
147
136
}()),
148
137
assert (() {
149
138
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)) {
152
141
throw FlutterError (
153
142
'Table contains irregular row lengths.\n '
154
143
'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 {
162
151
? children.map <Decoration ?>((TableRow row) => row.decoration).toList (growable: false )
163
152
: null {
164
153
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 );
166
155
return ! debugChildrenHaveDuplicateKeys (this , flatChildren, message:
167
156
'Two or more cells in this Table contain widgets with the same key.\n '
168
157
'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 {
238
227
RenderTable createRenderObject (BuildContext context) {
239
228
assert (debugCheckHasDirectionality (context));
240
229
return RenderTable (
241
- columns: children.isNotEmpty ? children[0 ].children! .length : 0 ,
230
+ columns: children.isNotEmpty ? children[0 ].children.length : 0 ,
242
231
rows: children.length,
243
232
columnWidths: columnWidths,
244
233
defaultColumnWidth: defaultColumnWidth,
@@ -254,7 +243,7 @@ class Table extends RenderObjectWidget {
254
243
@override
255
244
void updateRenderObject (BuildContext context, RenderTable renderObject) {
256
245
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 ));
258
247
assert (renderObject.rows == children.length);
259
248
renderObject
260
249
..columnWidths = columnWidths
@@ -289,7 +278,7 @@ class _TableElement extends RenderObjectElement {
289
278
rowIndex += 1 ;
290
279
return _TableElementRow (
291
280
key: row.key,
292
- children: row.children! .map <Element >((Widget child) {
281
+ children: row.children.map <Element >((Widget child) {
293
282
return inflateWidget (child, _TableSlot (columnIndex++ , rowIndex));
294
283
}).toList (growable: false ),
295
284
);
@@ -347,12 +336,12 @@ class _TableElement extends RenderObjectElement {
347
336
oldChildren = const < Element > [];
348
337
}
349
338
final List <_TableSlot > slots = List <_TableSlot >.generate (
350
- row.children! .length,
339
+ row.children.length,
351
340
(int columnIndex) => _TableSlot (columnIndex, rowIndex),
352
341
);
353
342
newChildren.add (_TableElementRow (
354
343
key: row.key,
355
- children: updateChildren (oldChildren, row.children! , forgottenChildren: _forgottenChildren, slots: slots),
344
+ children: updateChildren (oldChildren, row.children, forgottenChildren: _forgottenChildren, slots: slots),
356
345
));
357
346
}
358
347
while (oldUnkeyedRows.moveNext ()) {
0 commit comments