File tree Expand file tree Collapse file tree 2 files changed +36
-9
lines changed Expand file tree Collapse file tree 2 files changed +36
-9
lines changed Original file line number Diff line number Diff line change @@ -43,13 +43,14 @@ const htmlData = """
43
43
</p>
44
44
<table>
45
45
<colgroup>
46
- <col width="70%" />
46
+ <col width="50%" />
47
+ <col width="25%" />
48
+ <col width="25%" />
47
49
</colgroup>
48
50
<thead>
49
51
<tr><th>One</th><th>Two</th><th>Three</th></tr>
50
52
</thead>
51
53
<tbody>
52
- <tr><td><b>Data</b></td><td>Data</td><td>Data</td></tr>
53
54
<tr>
54
55
<td>Data</td><td>Data</td><td>Data</td>
55
56
</tr>
@@ -124,6 +125,20 @@ class _MyHomePageState extends State<MyHomePage> {
124
125
"#whitespace" : Style (
125
126
backgroundColor: Colors .purple,
126
127
),
128
+ "table" : Style (
129
+ backgroundColor: Color .fromARGB (0x50 , 0xee , 0xee , 0xee )
130
+ ),
131
+ "tr" : Style (
132
+ border: Border (bottom: BorderSide (color: Colors .grey))
133
+ ),
134
+ "th" : Style (
135
+ padding: EdgeInsets .all (6 ),
136
+ backgroundColor: Colors .grey
137
+ ),
138
+ "td" : Style (
139
+ padding: EdgeInsets .all (6 ),
140
+ backgroundColor: Colors .transparent
141
+ )
127
142
},
128
143
customRender: {
129
144
"flutter" : (RenderContext context, Widget child, attributes) {
Original file line number Diff line number Diff line change @@ -42,22 +42,25 @@ class TableLayoutElement extends LayoutElement {
42
42
});
43
43
}).expand ((i) => i).toList ().asMap ();
44
44
45
- return Table (
46
- columnWidths: colWidths,
47
- children: children
48
- .map ((c) {
45
+ return Container (
46
+ decoration: BoxDecoration (
47
+ color: style.backgroundColor
48
+ ),
49
+ child: Table (
50
+ columnWidths: colWidths,
51
+ children: children.map ((c) {
49
52
if (c is TableSectionLayoutElement ) {
50
53
return c.toTableRows (context);
51
54
}
52
55
return null ;
53
56
})
54
- .where ((t) {
57
+ .where ((t) {
55
58
return t != null ;
56
59
})
57
60
.toList ()
58
61
.expand ((i) => i)
59
62
.toList (),
60
- );
63
+ ) );
61
64
}
62
65
}
63
66
@@ -98,9 +101,18 @@ class TableRowLayoutElement extends LayoutElement {
98
101
99
102
TableRow toTableRow (RenderContext context) {
100
103
return TableRow (
104
+ decoration: BoxDecoration (
105
+ border: style.border,
106
+ ),
101
107
children: children.map ((c) {
102
108
if (c is StyledElement && c.name == 'td' || c.name == 'th' ) {
103
- return RichText (text: context.parser.parseTree (context, c));
109
+ return TableCell (
110
+ child: Container (
111
+ padding: c.style.padding,
112
+ decoration: BoxDecoration (
113
+ color: c.style.backgroundColor
114
+ ),
115
+ child: RichText (text: context.parser.parseTree (context, c))));
104
116
}
105
117
return null ;
106
118
}).where ((c) => c != null ).toList ());
You can’t perform that action at this time.
0 commit comments