1
+ import 'package:flutter/gestures.dart' ;
1
2
import 'package:flutter/material.dart' ;
2
3
import 'package:flutter_html/flutter_html.dart' ;
3
4
import 'package:flutter_html/html_parser.dart' ;
@@ -13,6 +14,7 @@ class MyApp extends StatelessWidget {
13
14
title: 'Flutter Demo' ,
14
15
theme: new ThemeData (
15
16
primarySwatch: Colors .blue,
17
+ brightness: Brightness .dark,
16
18
),
17
19
home: new MyHomePage (title: 'flutter_html Example' ),
18
20
);
@@ -35,15 +37,18 @@ const htmlData = """
35
37
<h4>Header 4</h4>
36
38
<h5>Header 5</h5>
37
39
<h6>Header 6</h6>
40
+ <h3>Ruby Support:</h3>
38
41
<p>
39
42
<ruby>
40
43
漢<rt>かん</rt>
41
44
字<rt>じ</rt>
42
45
</ruby>
43
- is Japanese Kanji
46
+ is Japanese Kanji.
44
47
</p>
48
+ <h3>Support for <code>sub</code>/<code>sup</code></h3>
45
49
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>
46
- <p>One of the most common equations in all of physics is <var>E</var>=<var>m</var><var>c</var><sup>2</sup>.<p>
50
+ <p>One of the most common equations in all of physics is <var>E</var>=<var>m</var><var>c</var><sup>2</sup>.</p>
51
+ <h3>Table support:</h3>
47
52
<table>
48
53
<colgroup>
49
54
<col width="50%" />
@@ -65,12 +70,16 @@ const htmlData = """
65
70
<tr><td>fData</td><td>fData</td><td>fData</td></tr>
66
71
</tfoot>
67
72
</table>
73
+ <h3>Custom Element Support:</h3>
68
74
<flutter></flutter>
75
+ <flutter horizontal></flutter>
76
+ <h3>SVG support:</h3>
69
77
<svg id='svg1' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'>
70
78
<circle r="32" cx="35" cy="65" fill="#F00" opacity="0.5"/>
71
79
<circle r="32" cx="65" cy="65" fill="#0F0" opacity="0.5"/>
72
80
<circle r="32" cx="50" cy="35" fill="#00F" opacity="0.5"/>
73
81
</svg>
82
+ <h3>List support:</h3>
74
83
<ol>
75
84
<li>This</li>
76
85
<li><p>is</p></li>
@@ -94,6 +103,21 @@ const htmlData = """
94
103
<li><h2>Header 2</h2></li>
95
104
<h2><li>Header 2</li></h2>
96
105
</ol>
106
+ <h3>Link support:</h3>
107
+ <p>
108
+ Linking to <a href='https://github.com'>websites</a> has never been easier.
109
+ </p>
110
+ <h3>Image support:</h3>
111
+ <p>
112
+ <img alt='Google' src='https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png' />
113
+ <a href='https://google.com'><img alt='Google' src='https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png' /></a>
114
+ <img alt='Alt Text of an intentionally broken image' src='https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30d' />
115
+ </p>
116
+ <h3>Video support:</h3>
117
+ <h3>Audio support:</h3>
118
+ <h3>IFrame support:</h3>
119
+
120
+
97
121
""" ;
98
122
99
123
class _MyHomePageState extends State <MyHomePage > {
@@ -113,21 +137,6 @@ class _MyHomePageState extends State<MyHomePage> {
113
137
backgroundColor: Colors .black,
114
138
color: Colors .white,
115
139
),
116
- "a" : Style (
117
- color: Colors .red,
118
- ),
119
- "li" : Style (
120
- // backgroundColor: Colors.red,
121
- // fontSize: FontSize(20),
122
- // margin: const EdgeInsets.only(top: 32),
123
- ),
124
- "h1, h3, h5" : Style (
125
- // backgroundColor: Colors.deepPurple,
126
- // alignment: Alignment.center,
127
- ),
128
- "#whitespace" : Style (
129
- backgroundColor: Colors .deepPurple,
130
- ),
131
140
"table" : Style (
132
141
backgroundColor: Color .fromARGB (0x50 , 0xee , 0xee , 0xee ),
133
142
),
@@ -140,7 +149,6 @@ class _MyHomePageState extends State<MyHomePage> {
140
149
),
141
150
"td" : Style (
142
151
padding: EdgeInsets .all (6 ),
143
- backgroundColor: Colors .transparent,
144
152
),
145
153
"var" : Style (fontFamily: 'serif' ),
146
154
},
@@ -161,19 +169,12 @@ class _MyHomePageState extends State<MyHomePage> {
161
169
onImageTap: (src) {
162
170
print (src);
163
171
},
172
+ onImageError: (exception, stackTrace) {
173
+ print (exception);
174
+ },
164
175
),
165
176
),
166
177
),
167
- Expanded (
168
- child: SingleChildScrollView (
169
- child: Text (
170
- HtmlParser .cleanTree (HtmlParser .applyCSS (
171
- HtmlParser .lexDomTree (HtmlParser .parseHTML (htmlData), [], []), null ))
172
- .toString (),
173
- style: TextStyle (fontFamily: 'monospace' ),
174
- ),
175
- ),
176
- )
177
178
],
178
179
),
179
180
),
0 commit comments