You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-3Lines changed: 23 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,8 @@ A Flutter widget for rendering HTML and CSS as Flutter widgets.
34
34
-[API Reference](#api-reference)
35
35
36
36
-[Constructors](#constructors)
37
+
38
+
-[Selectable Text](#selectable-text)
37
39
38
40
-[Parameters Table](#parameters)
39
41
@@ -143,14 +145,30 @@ For a full example, see [here](https://github.com/Sub6Resources/flutter_html/tre
143
145
144
146
Below, you will find brief descriptions of the parameters the`Html` widget accepts and some code snippets to help you use this package.
145
147
146
-
## Constructors:
148
+
###Constructors:
147
149
148
150
The package currently has two different constructors - `Html()` and `Html.fromDom()`.
149
151
150
152
The `Html()` constructor is for those who would like to directly pass HTML from the source to the package to be rendered.
151
153
152
154
If you would like to modify or sanitize the HTML before rendering it, then `Html.fromDom()` is for you - you can convert the HTML string to a `Document` and use its methods to modify the HTML as you wish. Then, you can directly pass the modified `Document` to the package. This eliminates the need to parse the modified `Document` back to a string, pass to `Html()`, and convert back to a `Document`, thus cutting down on load times.
153
155
156
+
#### Selectable Text
157
+
158
+
The package also has two constructors for selectable text support - `SelectableHtml()` and `SelectableHtml.fromDom()`.
159
+
160
+
The difference between the two is the same as noted above.
161
+
162
+
Please note: Due to Flutter [#38474](https://github.com/flutter/flutter/issues/38474), selectable text support is significantly watered down compared to the standard non-selectable version of the widget. The changes are as follows:
163
+
164
+
1. The list of tags that can be rendered is significantly reduced. Key omissions include no support for images/video/audio, table, and ul/ol.
165
+
166
+
2. No support for `customRender`, `customImageRender`, `onImageError`, `onImageTap`, `onMathError`, and `navigationDelegateForIframe`. (Support for `customRender` may be added in the future).
167
+
168
+
3. Styling support is significantly reduced. Only text-related styling works (e.g. bold or italic), while container related styling (e.g. borders or padding/margin) do not work.
169
+
170
+
Once the above issue is resolved, the aforementioned compromises will go away. Currently the `SelectableText.rich()` constructor does not support `WidgetSpan`s, resulting in the feature losses above.
171
+
154
172
### Parameters:
155
173
156
174
| Parameters | Description |
@@ -170,7 +188,9 @@ If you would like to modify or sanitize the HTML before rendering it, then `Html
170
188
171
189
### Getters:
172
190
173
-
Currently the only getter is `Html.tags`. This provides a list of all the tags the package renders. The main use case is to assist in blacklisting elements using `tagsList`. See an [example](#example-usage---tagslist---excluding-tags) below.
191
+
1.`Html.tags`. This provides a list of all the tags the package renders. The main use case is to assist in excluding elements using `tagsList`. See an [example](#example-usage---tagslist---excluding-tags) below.
192
+
193
+
2.`SelectableHtml.tags`. This provides a list of all the tags that can be rendered in selectable mode.
174
194
175
195
### Data:
176
196
@@ -419,7 +439,7 @@ A list of elements the `Html` widget should render. The list should contain the
419
439
#### Example Usage - tagsList - Excluding Tags:
420
440
You may have instances where you can choose between two different types of HTML tags to display the same content. In the example below, the `<video>` and `<iframe>` elements are going to display the same content.
421
441
422
-
The `blacklistedElements` parameter allows you to change which element is rendered. Iframes can be advantageous because they allow parallel loading - Flutter just has to wait for the webview to be initialized before rendering the page, possibly cutting down on load time. Video can be advantageous because it provides a 100% native experience with Flutter widgets, but it may take more time to render the page. You may know that Flutter webview is a little janky in its current state on Android, so using `blacklistedElements` and a simple condition, you can get the best of both worlds - choose the video widget to render on Android and the iframe webview to render on iOS.
442
+
The `tagsList` parameter allows you to change which element is rendered. Iframes can be advantageous because they allow parallel loading - Flutter just has to wait for the webview to be initialized before rendering the page, possibly cutting down on load time. Video can be advantageous because it provides a 100% native experience with Flutter widgets, but it may take more time to render the page. You may know that Flutter webview is a little janky in its current state on Android, so using `tagsList` and a simple condition, you can get the best of both worlds - choose the video widget to render on Android and the iframe webview to render on iOS.
0 commit comments