Skip to content

Commit 6a8e58b

Browse files
Merge pull request #122 from Sub6Resources/new-parser
Version 1.0.0
2 parents e03bdaf + 0980df6 commit 6a8e58b

File tree

163 files changed

+4857
-3422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+4857
-3422
lines changed

.circleci/config.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
version: 2
1+
version: 2.1
2+
orbs:
3+
codecov: codecov/codecov@1.0.2
24
jobs:
35
build:
46
docker:
57
- image: cirrusci/flutter
68
steps:
79
- checkout
810
- run: flutter --version
9-
- run: flutter test
11+
- run: flutter test --coverage
12+
- codecov/upload:
13+
file: coverage/lcov.info

.github/flutter_html_screenshot.png

114 KB
Loading

.github/flutter_html_screenshot2.png

244 KB
Loading

.github/flutter_html_screenshot3.png

258 KB
Loading

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,5 @@ modules.xml
146146
# End of https://www.gitignore.io/api/flutter,jetbrains+all
147147

148148
**/.flutter-plugins-dependencies
149+
150+
**/flutter_export_environment.sh

.metadata

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: 20e59316b8b8474554b38493b8ca888794b0234a
8+
channel: stable
9+
10+
project_type: package

CHANGELOG.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
# [1.0.0]
2+
* BREAKING CHANGES (see the [Migration Guide](https://github.com/Sub6Resources/flutter_html/wiki/1.0.0-Migration-Guide) for a full overview of breaking changes.):
3+
* The default parser has been completely rewritten and the RichText parser has been removed.
4+
* `useRichText` no longer is necessary (The new parser uses RichText under the hood)
5+
* `customRender` now works for the default parser.
6+
* Adds support for `<audio>`, `<video>`, `<iframe>`, `<svg>`, `<ruby>`, `<rt>`, `<rp>`, `<sub>`, and `<sup>`
7+
* Adds support for over 20 CSS attributes when using the `style` parameter.
8+
* Fixes many many issues (see the list at [#122](https://github.com/Sub6Resources/flutter_html/pull/122))
9+
* The following parameters of `Html` have been removed and should no longer be used (see the migration guide):
10+
* `useRichText`
11+
* `padding`
12+
* `backgroundColor`
13+
* `defaultTextStyle`
14+
* `renderNewlines`
15+
* `customEdgeInsets`
16+
* `customTextStyle`
17+
* `blockSpacing`
18+
* `customTextAlign`
19+
* `linkStyle`
20+
* `imageProperties`
21+
* `showImages`
22+
* The default text style now matches the app's Material `TextTheme.bodyText2` (Fixes [#18](https://github.com/Sub6Resources/flutter_html/issues/18)).
23+
* Requires Flutter v1.17.0 or greater
24+
* Fixed quite a few issues with `img`
25+
* Added a fancy new `style` attribute (this should be used in place of the deprecated styling parameters).
26+
27+
## [1.0.0-pre.1] - December 27, 2019
28+
29+
* For a list of pre-release changes, including several BREAKING CHANGES, see release notes for 1.0.0 above.
30+
131
## [0.11.1] - December 14, 2019:
232

333
* Add support for `AssetImage`s using the `asset:` prefix ([#162](https://github.com/Sub6Resources/flutter_html/pull/162)).
@@ -42,7 +72,6 @@
4272
* Add support for `address` tag in `RichText` parser.
4373

4474
## [0.9.7] - May 13, 2019:
45-
4675
* Added onImageError callback
4776
* Added custom textstyle and edgeinsets callback ([#72](https://github.com/Sub6Resources/flutter_html/pull/72))
4877
* Update dependency versions ([#84](https://github.com/Sub6Resources/flutter_html/issues/84))

README.md

Lines changed: 35 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,72 @@
11
# flutter_html
22
[![pub package](https://img.shields.io/pub/v/flutter_html.svg)](https://pub.dev/packages/flutter_html)
3+
[![codecov](https://codecov.io/gh/Sub6Resources/flutter_html/branch/master/graph/badge.svg)](https://codecov.io/gh/Sub6Resources/flutter_html)
34
[![CircleCI](https://circleci.com/gh/Sub6Resources/flutter_html.svg?style=svg)](https://circleci.com/gh/Sub6Resources/flutter_html)
5+
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/Sub6Resources/flutter_html/blob/master/LICENSE)
46

5-
> **Note: 1.0.0-pre.1 has been released! See the [Migration Guide](https://github.com/Sub6Resources/flutter_html/wiki/1.0.0-Migration-Guide) if you'd like to take advantage of all the new features of 1.0.0! Also, check out the [Prerelease Changelog](https://github.com/Sub6Resources/flutter_html/blob/new-parser/PRE_CHANGELOG.md).** Version 1.0.0 is currently on the `new-parser` branch. This README will be updated when 1.0.0 is merged into the master branch.
6-
7-
A Flutter widget for rendering static html tags as Flutter widgets. (Will render over 70 different html tags!)
7+
A Flutter widget for rendering html and css as Flutter widgets.
88

99
<img alt="A Screenshot of flutter_html" src=".github/flutter_html_screenshot.png" width="300"/>
10+
<img alt="Another Screenshot of flutter_html" src=".github/flutter_html_screenshot2.png" width="300"/>
11+
<img alt="Yet another Screenshot of flutter_html" src=".github/flutter_html_screenshot3.png" width="300"/>
1012

1113
## Installing:
1214

1315
Add the following to your `pubspec.yaml` file:
1416

1517
dependencies:
16-
flutter_html: ^0.11.1
18+
flutter_html: ^1.0.0-pre.1
1719

1820
## Currently Supported HTML Tags:
1921
`a`, `abbr`, `acronym`, `address`, `article`, `aside`, `b`, `bdi`, `bdo`, `big`, `blockquote`, `body`, `br`, `caption`, `cite`, `code`, `data`, `dd`, `del`, `dfn`, `div`, `dl`, `dt`, `em`, `figcaption`, `figure`, `footer`, `h1`, `h2`, `h3`, `h4`, `h5`, `h6`, `header`, `hr`, `i`, `img`, `ins`, `kbd`, `li`, `main`, `mark`, `nav`, `noscript`, `ol`, `p`, `pre`, `q`, `rp`, `rt`, `ruby`, `s`, `samp`, `section`, `small`, `span`, `strike`, `strong`, `sub`, `sup`, `table`, `tbody`, `td`, `template`, `tfoot`, `th`, `thead`, `time`, `tr`, `tt`, `u`, `ul`, `var`
2022

21-
## Roadmap
22-
[View the development roadmap in the wiki](https://github.com/Sub6Resources/flutter_html/wiki/Roadmap)
23-
24-
### Partially supported elements:
25-
> These are common elements that aren't yet fully supported, but won't be ignored and will still render somewhat correctly.
26-
27-
`center`, `font`
23+
## Currently Supported CSS Attributes:
24+
> Coming soon!
2825
29-
### List of _planned_ supported elements:
30-
> These are elements that are planned, but present a specific challenge that makes them somewhat difficult to implement.
31-
32-
`audio`, `details`, `source`, `summary`, `svg`, `track`, `video`, `wbr`
33-
34-
### List of elements that I don't plan on implementing:
26+
### Elements with planned support:
3527

36-
> Feel free to open an issue if you have a good reason and feel like you can convince me to implement
37-
them. A _well written_ and _complete_ pull request implementing one of these is always welcome,
38-
though I cannot promise I will merge them.
39-
40-
> Note: These unsupported tags will just be ignored.
41-
42-
`applet`, `area`, `base`, `basefont`, `button`, `canvas`, `col`, `colgroup`, `datalist`, `dialog`, `dir`, `embed`, `fieldset`, `form`, `frame`, `frameset`, `head`, `iframe`, `input`, `label`, `legend`, `link`, `map`, `meta`, `meter`, `noframe`, `object`, `optgroup`, `option`, `output`, `param`, `picture`, `progress`, `script`, `select`, `style`, `textarea`, `title`
43-
28+
See the [development roadmap](https://github.com/Sub6Resources/flutter_html/wiki/Roadmap) for the list of elements and css attributes I plan on supporting.
4429

4530
## Why this package?
4631

47-
This package is designed with simplicity in mind. Flutter currently does not support rendering of web content
48-
into the widget tree. This package is designed to be a reasonable alternative for rendering static web content
49-
until official support is added.
50-
51-
### Update:
52-
The official Flutter WebView package has been created and is in a developer preview. It's not stable yet, so I'll continue to support this project at least until webview_flutter hits 1.0.0.
53-
54-
Check out the official Flutter WebView package here: https://pub.dartlang.org/packages/webview_flutter
55-
32+
This package is designed with simplicity in mind. Originally created to allow basic rendering of HTML content into the Flutter widget tree,
33+
this project has expanded to include support for basic styling as well!.
5634

5735
## Example Usage:
58-
59-
Html(
36+
(For a much more extensive example, look at example/main.dart).
37+
```dart
38+
Widget html = Html(
6039
data: """
61-
<!--For a much more extensive example, look at example/main.dart-->
6240
<div>
6341
<h1>Demo Page</h1>
64-
<p>This is a fantastic nonexistent product that you should buy!</p>
65-
<h2>Pricing</h2>
66-
<p>Lorem ipsum <b>dolor</b> sit amet.</p>
67-
<h2>The Team</h2>
68-
<p>There isn't <i>really</i> a team...</p>
69-
<h2>Installation</h2>
70-
<p>You <u>cannot</u> install a nonexistent product!</p>
42+
<p>This is a fantastic product that you should buy!</p>
43+
<h3>Features</h3>
44+
<ul>
45+
<li>It actually works</li>
46+
<li>It exists</li>
47+
<li>It doesn't cost much!</li>
48+
</ul>
7149
<!--You can pretty much put any html in here!-->
7250
</div>
7351
""",
7452
//Optional parameters:
75-
padding: EdgeInsets.all(8.0),
7653
backgroundColor: Colors.white70,
77-
defaultTextStyle: TextStyle(fontFamily: 'serif'),
78-
linkStyle: const TextStyle(
79-
color: Colors.redAccent,
80-
),
8154
onLinkTap: (url) {
8255
// open url in a webview
8356
},
57+
style: {
58+
"div": Style(
59+
block: Block(
60+
margin: EdgeInsets.all(16),
61+
border: Border.all(width: 6),
62+
backgroundColor: Colors.grey,
63+
),
64+
textStyle: TextStyle(
65+
color: Colors.red,
66+
),
67+
),
68+
},
8469
onImageTap: (src) {
8570
// Display the image in large form.
8671
},
87-
//Must have useRichText set to false for this to work.
88-
customRender: (node, children) {
89-
if(node is dom.Element) {
90-
switch(node.localName) {
91-
case "video": return Chewie(...);
92-
case "custom_tag": return CustomWidget(...);
93-
}
94-
}
95-
},
96-
customTextAlign: (dom.Node node) {
97-
if (node is dom.Element) {
98-
switch (node.localName) {
99-
case "p":
100-
return TextAlign.justify;
101-
}
102-
}
103-
},
104-
customTextStyle: (dom.Node node, TextStyle baseStyle) {
105-
if (node is dom.Element) {
106-
switch (node.localName) {
107-
case "p":
108-
return baseStyle.merge(TextStyle(height: 2, fontSize: 20));
109-
}
110-
}
111-
return baseStyle;
112-
},
113-
)
114-
115-
## `useRichText` parameter
116-
117-
This package has a known issue where text does not wrap correctly. Setting `useRichText` to true fixes the issue
118-
by using an alternate parser. The alternate parser, however, does not support the `customRender` callback, and several elements
119-
supported by the default parser are not supported by the alternate parser (see [#61](https://github.com/Sub6Resources/flutter_html/issues/61) for a list).
72+
);

example/.gitignore

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
.dart_tool/
26+
.flutter-plugins
27+
.packages
28+
.pub-cache/
29+
.pub/
30+
/build/
31+
32+
# Android related
33+
**/android/**/gradle-wrapper.jar
34+
**/android/.gradle
35+
**/android/captures/
36+
**/android/gradlew
37+
**/android/gradlew.bat
38+
**/android/local.properties
39+
**/android/**/GeneratedPluginRegistrant.java
40+
41+
# iOS/XCode related
42+
**/ios/**/*.mode1v3
43+
**/ios/**/*.mode2v3
44+
**/ios/**/*.moved-aside
45+
**/ios/**/*.pbxuser
46+
**/ios/**/*.perspectivev3
47+
**/ios/**/*sync/
48+
**/ios/**/.sconsign.dblite
49+
**/ios/**/.tags*
50+
**/ios/**/.vagrant/
51+
**/ios/**/DerivedData/
52+
**/ios/**/Icon?
53+
**/ios/**/Pods/
54+
**/ios/**/.symlinks/
55+
**/ios/**/profile
56+
**/ios/**/xcuserdata
57+
**/ios/.generated/
58+
**/ios/Flutter/App.framework
59+
**/ios/Flutter/Flutter.framework
60+
**/ios/Flutter/Generated.xcconfig
61+
**/ios/Flutter/app.flx
62+
**/ios/Flutter/app.zip
63+
**/ios/Flutter/flutter_assets/
64+
**/ios/ServiceDefinitions.json
65+
**/ios/Runner/GeneratedPluginRegistrant.*
66+
67+
# Exceptions to above rules.
68+
!**/ios/**/default.mode1v3
69+
!**/ios/**/default.mode2v3
70+
!**/ios/**/default.pbxuser
71+
!**/ios/**/default.perspectivev3
72+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
73+
74+
**/.flutter-plugins-dependencies
75+
**/ios/Flutter/flutter_export_environment.sh

example/.metadata

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: 20e59316b8b8474554b38493b8ca888794b0234a
8+
channel: stable
9+
10+
project_type: app

0 commit comments

Comments
 (0)