Skip to content

Commit b6c045e

Browse files
committed
Support exactly-specified widths and height from css
1 parent 17efea1 commit b6c045e

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

example/lib/main.dart

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,13 @@ const htmlData = r"""
6161
<p>
6262
<q>Famous quote...</q>
6363
</p>
64-
<table>
65-
<colgroup>
66-
<col width="50%" />
67-
<col span="2" width="25%" />
68-
</colgroup>
64+
<table style="height: 400">
6965
<thead>
7066
<tr><th>One</th><th>Two</th><th>Three</th></tr>
7167
</thead>
7268
<tbody>
7369
<tr>
74-
<td rowspan='2'>Rowspan\nRowspan\nRowspan\nRowspan\nRowspan\nRowspan\nRowspan\nRowspan\nRowspan\nRowspan</td><td>Data</td><td>Data</td>
70+
<td rowspan='2'>Rowspan</td><td>Data</td><td>Data</td>
7571
</tr>
7672
<tr>
7773
<td colspan="2"><img alt='Google' src='https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png' /></td>
@@ -268,13 +264,13 @@ class _MyHomePageState extends State<MyHomePage> {
268264
'h5': Style(maxLines: 2, textOverflow: TextOverflow.ellipsis),
269265
},
270266
customRender: {
271-
"table": (context, child) {
272-
return SingleChildScrollView(
273-
scrollDirection: Axis.horizontal,
274-
child:
275-
(context.tree as TableLayoutElement).toWidget(context),
276-
);
277-
},
267+
// "table": (context, child) {
268+
// return SingleChildScrollView(
269+
// scrollDirection: Axis.horizontal,
270+
// child:
271+
// (context.tree as TableLayoutElement).toWidget(context),
272+
// );
273+
// },
278274
"bird": (RenderContext context, Widget child) {
279275
return TextSpan(text: "🐦");
280276
},

lib/src/css_parser.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ Style declarationsToStyle(Map<String, List<css.Expression>> declarations) {
194194
case 'font-weight':
195195
style.fontWeight = ExpressionMapping.expressionToFontWeight(value.first);
196196
break;
197+
case 'height':
198+
style.height = ExpressionMapping.expressionToPaddingLength(value.first) ?? style.height;
199+
break;
197200
case 'list-style-type':
198201
if (value.first is css.LiteralTerm) {
199202
style.listStyleType = ExpressionMapping.expressionToListStyleType(value.first as css.LiteralTerm) ?? style.listStyleType;
@@ -298,6 +301,9 @@ Style declarationsToStyle(Map<String, List<css.Expression>> declarations) {
298301
case 'text-shadow':
299302
style.textShadow = ExpressionMapping.expressionToTextShadow(value);
300303
break;
304+
case 'width':
305+
style.width = ExpressionMapping.expressionToPaddingLength(value.first) ?? style.width;
306+
break;
301307
}
302308
}
303309
});

0 commit comments

Comments
 (0)