@@ -31,6 +31,18 @@ class TableLayoutElement extends LayoutElement {
31
31
32
32
@override
33
33
Widget toWidget (RenderContext context) {
34
+ return Container (
35
+ decoration: BoxDecoration (
36
+ color: style.backgroundColor,
37
+ border: style.border,
38
+ ),
39
+ width: style.width,
40
+ height: style.height,
41
+ child: _layoutCells (context),
42
+ );
43
+ }
44
+
45
+ Widget _layoutCells (RenderContext context) {
34
46
final rows = < TableRowLayoutElement > [];
35
47
List <TrackSize > columnSizes = < TrackSize > [];
36
48
for (var child in children) {
@@ -48,14 +60,14 @@ class TableLayoutElement extends LayoutElement {
48
60
colWidth.substring (0 , colWidth.length - 1 ));
49
61
return percentageSize != null && ! percentageSize.isNaN
50
62
? FlexibleTrackSize (percentageSize * 0.01 )
51
- : FlexibleTrackSize ( 1 );
63
+ : IntrinsicContentTrackSize ( );
52
64
} else if (colWidth != null ) {
53
65
final fixedPxSize = double .tryParse (colWidth);
54
66
return fixedPxSize != null
55
67
? FixedTrackSize (fixedPxSize)
56
- : FlexibleTrackSize ( 1 );
68
+ : IntrinsicContentTrackSize ( );
57
69
} else {
58
- return FlexibleTrackSize ( 1 );
70
+ return IntrinsicContentTrackSize ( );
59
71
}
60
72
});
61
73
})
@@ -101,7 +113,8 @@ class TableLayoutElement extends LayoutElement {
101
113
),
102
114
child: SizedBox .expand (
103
115
child: Container (
104
- alignment: child.style.alignment ?? style.alignment ??
116
+ alignment: child.style.alignment ??
117
+ style.alignment ??
105
118
Alignment .centerLeft,
106
119
child: StyledText (
107
120
textSpan: context.parser.parseTree (context, child),
@@ -123,29 +136,21 @@ class TableLayoutElement extends LayoutElement {
123
136
}
124
137
125
138
// Create column tracks (insofar there were no colgroups that already defined them)
126
- List <TrackSize > finalColumnSizes = (columnSizes ?? < TrackSize > []). take (
127
- columnMax).toList ();
139
+ List <TrackSize > finalColumnSizes =
140
+ (columnSizes ?? < TrackSize > []). take ( columnMax).toList ();
128
141
finalColumnSizes += List .generate (
129
142
max (0 , columnMax - finalColumnSizes.length),
130
- (_) => FlexibleTrackSize (1 ));
131
- return Container (
132
- decoration: BoxDecoration (
133
- color: style.backgroundColor,
134
- border: style.border,
135
- ),
136
- width: style.width,
137
- height: style.height,
138
- child: LayoutGrid (
139
- gridFit: GridFit .loose,
140
- templateColumnSizes: finalColumnSizes,
141
- templateRowSizes: rowSizes,
142
- children: cells,
143
- ),
143
+ (_) => IntrinsicContentTrackSize ());
144
+
145
+ return LayoutGrid (
146
+ gridFit: GridFit .loose,
147
+ templateColumnSizes: finalColumnSizes,
148
+ templateRowSizes: rowSizes,
149
+ children: cells,
144
150
);
145
151
}
146
152
}
147
153
148
-
149
154
class TableSectionLayoutElement extends LayoutElement {
150
155
TableSectionLayoutElement ({
151
156
String name,
@@ -185,12 +190,12 @@ class TableCellElement extends StyledElement {
185
190
Style style,
186
191
dom.Element node,
187
192
}) : super (
188
- name: name,
189
- elementId: elementId,
190
- elementClasses: elementClasses,
191
- children: children,
192
- style: style,
193
- node: node) {
193
+ name: name,
194
+ elementId: elementId,
195
+ elementClasses: elementClasses,
196
+ children: children,
197
+ style: style,
198
+ node: node) {
194
199
colspan = _parseSpan (this , "colspan" );
195
200
rowspan = _parseSpan (this , "rowspan" );
196
201
}
@@ -201,8 +206,9 @@ class TableCellElement extends StyledElement {
201
206
}
202
207
}
203
208
204
- TableCellElement parseTableCellElement (dom.Element element,
205
- List <StyledElement > children,
209
+ TableCellElement parseTableCellElement (
210
+ dom.Element element,
211
+ List <StyledElement > children,
206
212
) {
207
213
final cell = TableCellElement (
208
214
name: element.localName,
@@ -228,8 +234,9 @@ class TableStyleElement extends StyledElement {
228
234
}) : super (name: name, children: children, style: style, node: node);
229
235
}
230
236
231
- TableStyleElement parseTableDefinitionElement (dom.Element element,
232
- List <StyledElement > children,
237
+ TableStyleElement parseTableDefinitionElement (
238
+ dom.Element element,
239
+ List <StyledElement > children,
233
240
) {
234
241
switch (element.localName) {
235
242
case "colgroup" :
@@ -244,8 +251,9 @@ TableStyleElement parseTableDefinitionElement(dom.Element element,
244
251
}
245
252
}
246
253
247
- LayoutElement parseLayoutElement (dom.Element element,
248
- List <StyledElement > children,
254
+ LayoutElement parseLayoutElement (
255
+ dom.Element element,
256
+ List <StyledElement > children,
249
257
) {
250
258
switch (element.localName) {
251
259
case "table" :
0 commit comments