Skip to content

Commit 6618e65

Browse files
committed
Add table with horizontal scroll as custom render example
1 parent 0192cef commit 6618e65

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,32 @@ Widget html = Html(
271271
);
272272
```
273273

274-
2. Complex example - rendering an `iframe` differently based on whether it is an embedded youtube video or some other embedded content
274+
2. Complex example - wrapping the default widget with your own, in this case placing a horizontal scroll around a (potentially too wide) table.
275+
276+
<details><summary>View code</summary>
277+
278+
```dart
279+
Widget html = Html(
280+
data: """
281+
<table style="width:100%">
282+
<caption>Monthly savings</caption>
283+
<tr> <th>January</th> <th>February</th> <th>March</th> <th>April</th> <th>May</th> <th>June</th> <th>July</th> <th>August</th> <th>September</th> <th>October</th> <th>November</th> <th>December</th> </tr>
284+
<tr> <td>\$100</td> <td>\$50</td> <td>\$80</td> <td>\$60</td> <td>\$90</td> <td>\$140</td> <td>\$110</td> <td>\$80</td> <td>\$90</td> <td>\$60</td> <td>\$40</td> <td>\$70</td> </tr>
285+
<tr> <td>\90</td> <td>\$60</td> <td>\$80</td> <td>\$80</td> <td>\$100</td> <td>\$160</td> <td>\$150</td> <td>\$110</td> <td>\$100</td> <td>\$60</td> <td>\$30</td> <td>\$80</td> </tr>
286+
</table>
287+
""",
288+
customRender: {
289+
"table": (context, child) {
290+
return SingleChildScrollView(
291+
scrollDirection: Axis.horizontal,
292+
child: (context.tree as TableLayoutElement).toWidget(context),
293+
);
294+
}
295+
},
296+
);
297+
```
298+
299+
3. Complex example - rendering an `iframe` differently based on whether it is an embedded youtube video or some other embedded content.
275300

276301
<details><summary>View code</summary>
277302

0 commit comments

Comments
 (0)