Skip to content

Commit a5e5c8c

Browse files
author
Nguyen Dat
committed
change style
1 parent 3e026f5 commit a5e5c8c

File tree

1 file changed

+56
-75
lines changed

1 file changed

+56
-75
lines changed

example/lib/main.dart

Lines changed: 56 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const htmlData = r"""
4141
</ruby>
4242
&nbsp;is Japanese Kanji.
4343
</p>
44+
<h3>Support for maxLines:</h3>
45+
<h5>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vestibulum sapien feugiat lorem tempor, id porta orci elementum. Fusce sed justo id arcu egestas congue. Fusce tincidunt lacus ipsum, in imperdiet felis ultricies eu. In ullamcorper risus felis, ac maximus dui bibendum vel. Integer ligula tortor, facilisis eu mauris ut, ultrices hendrerit ex. Donec scelerisque massa consequat, eleifend mauris eu, mollis dui. Donec placerat augue tortor, et tincidunt quam tempus non. Quisque sagittis enim nisi, eu condimentum lacus egestas ac. Nam facilisis luctus ipsum, at aliquam urna fermentum a. Quisque tortor dui, faucibus in ante eget, pellentesque mattis nibh. In augue dolor, euismod vitae eleifend nec, tempus vel urna. Donec vitae augue accumsan ligula fringilla ultrices et vel ex.</h5>
4446
<h3>Support for <code>sub</code>/<code>sup</code></h3>
4547
Solve for <var>x<sub>n</sub></var>: log<sub>2</sub>(<var>x</var><sup>2</sup>+<var>n</var>) = 9<sup>3</sup>
4648
<p>One of the most <span>common</span> equations in all of physics is <br /><var>E</var>=<var>m</var><var>c</var><sup>2</sup>.</p>
@@ -246,84 +248,63 @@ class _MyHomePageState extends State<MyHomePage> {
246248
centerTitle: true,
247249
),
248250
body: SingleChildScrollView(
249-
child: Column(
250-
children: [
251-
Html(
252-
data: htmlData,
253-
style: {
254-
"table": Style(
255-
backgroundColor: Color.fromARGB(0x50, 0xee, 0xee, 0xee),
256-
),
257-
"tr": Style(
258-
border: Border(bottom: BorderSide(color: Colors.grey)),
259-
),
260-
"th": Style(
261-
padding: EdgeInsets.all(6),
262-
backgroundColor: Colors.grey,
263-
),
264-
"td": Style(
265-
padding: EdgeInsets.all(6),
266-
alignment: Alignment.topLeft,
267-
),
268-
},
269-
customRender: {
270-
"table": (context, child) {
271-
return SingleChildScrollView(
272-
scrollDirection: Axis.horizontal,
273-
child:
274-
(context.tree as TableLayoutElement).toWidget(context),
275-
);
276-
}
277-
},
278-
customImageRenders: {
279-
networkSourceMatcher(domains: ["flutter.dev"]):
280-
(context, attributes, element) {
281-
return FlutterLogo(size: 36);
282-
},
283-
networkSourceMatcher(domains: ["mydomain.com"]):
284-
networkImageRender(
285-
headers: {"Custom-Header": "some-value"},
286-
altWidget: (alt) => Text(alt ?? ""),
287-
loadingWidget: () => Text("Loading..."),
288-
),
289-
// On relative paths starting with /wiki, prefix with a base url
290-
(attr, _) =>
291-
attr["src"] != null && attr["src"]!.startsWith("/wiki"):
292-
networkImageRender(
293-
mapUrl: (url) => "https://upload.wikimedia.org" + url!),
294-
// Custom placeholder image for broken links
295-
networkSourceMatcher():
296-
networkImageRender(altWidget: (_) => FlutterLogo()),
297-
},
298-
onLinkTap: (url, _, __, ___) {
299-
print("Opening $url...");
300-
},
301-
onImageTap: (src, _, __, ___) {
302-
print(src);
303-
},
304-
onImageError: (exception, stackTrace) {
305-
print(exception);
306-
},
251+
child: Html(
252+
data: htmlData,
253+
style: {
254+
"table": Style(
255+
backgroundColor: Color.fromARGB(0x50, 0xee, 0xee, 0xee),
307256
),
308-
Text('h3 tag with maxLines = 1'),
309-
Html(
310-
data: htmlDataLines,
311-
style: {
312-
'h3': Style(maxLines: 1, textOverflow: TextOverflow.ellipsis),
313-
},
257+
"tr": Style(
258+
border: Border(bottom: BorderSide(color: Colors.grey)),
314259
),
315-
Text('h3 tag with maxLines = 2'),
316-
Html(
317-
data: htmlDataLines,
318-
style: {
319-
'h3': Style(maxLines: 2, textOverflow: TextOverflow.ellipsis),
320-
},
260+
"th": Style(
261+
padding: EdgeInsets.all(6),
262+
backgroundColor: Colors.grey,
321263
),
322-
Text('h3 tag with unlimit lines'),
323-
Html(
324-
data: htmlDataLines,
325-
)
326-
],
264+
"td": Style(
265+
padding: EdgeInsets.all(6),
266+
alignment: Alignment.topLeft,
267+
),
268+
'h5': Style(maxLines: 2, textOverflow: TextOverflow.ellipsis),
269+
},
270+
customRender: {
271+
"table": (context, child) {
272+
return SingleChildScrollView(
273+
scrollDirection: Axis.horizontal,
274+
child:
275+
(context.tree as TableLayoutElement).toWidget(context),
276+
);
277+
}
278+
},
279+
customImageRenders: {
280+
networkSourceMatcher(domains: ["flutter.dev"]):
281+
(context, attributes, element) {
282+
return FlutterLogo(size: 36);
283+
},
284+
networkSourceMatcher(domains: ["mydomain.com"]):
285+
networkImageRender(
286+
headers: {"Custom-Header": "some-value"},
287+
altWidget: (alt) => Text(alt ?? ""),
288+
loadingWidget: () => Text("Loading..."),
289+
),
290+
// On relative paths starting with /wiki, prefix with a base url
291+
(attr, _) =>
292+
attr["src"] != null && attr["src"]!.startsWith("/wiki"):
293+
networkImageRender(
294+
mapUrl: (url) => "https://upload.wikimedia.org" + url!),
295+
// Custom placeholder image for broken links
296+
networkSourceMatcher():
297+
networkImageRender(altWidget: (_) => FlutterLogo()),
298+
},
299+
onLinkTap: (url, _, __, ___) {
300+
print("Opening $url...");
301+
},
302+
onImageTap: (src, _, __, ___) {
303+
print(src);
304+
},
305+
onImageError: (exception, stackTrace) {
306+
print(exception);
307+
},
327308
),
328309
),
329310
);

0 commit comments

Comments
 (0)