Skip to content

Commit 4118016

Browse files
committed
Version 0.1.1
1 parent ba5ae61 commit 4118016

File tree

7 files changed

+177
-84
lines changed

7 files changed

+177
-84
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [0.1.1] - August 14, 2018:
2+
3+
* Fixed `b` to be bold, not italic...
4+
* Adds support for `em`, and `strong`
5+
* Add support for a default `TextStyle`
6+
17
## [0.1.0] - August 14, 2018:
28

39
* Renamed widget from `HtmlWidget` to `Html`

README.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# flutter_html_widget
1+
# flutter_html
22

33
A Flutter widget for rendering static html tags as Flutter widgets.
44

@@ -7,44 +7,50 @@ A Flutter widget for rendering static html tags as Flutter widgets.
77
Add the following to your `pubspec.yaml` file:
88

99
dependencies:
10-
flutter_html_widget: ^0.1.0
11-
12-
## Usage:
13-
14-
Html(
15-
data: """
16-
<div>
17-
<h1>Demo Page</h1>
18-
<p>This is a fantastic nonexistent product that you should buy!</p>
19-
<h2>Pricing</h2>
20-
<p>Lorem ipsum <b>dolor</b> sit amet.</p>
21-
<h2>The Team</h2>
22-
<p>There isn't <i>really</i> a team...</p>
23-
<h2>Installation</h2>
24-
<p>You <u>cannot</u> install a nonexistent product!</p>
25-
</div>
26-
""",
27-
//Optional parameters:
28-
padding: EdgeInsets.all(8.0),
29-
backgroundColor: Colors.white70,
30-
)
10+
flutter_html: ^0.1.1
3111

3212
## Currently Supported HTML Tags:
3313

3414
* `b`
3515
* `body`
3616
* `div`
17+
* `em`
18+
* `h1` - `h6`
3719
* `i`
3820
* `p`
21+
* `strong`
3922
* `u`
40-
* `h1` - `h6`
4123

4224
Here are a list of elements that this package will never support:
4325

4426
* `script`
27+
* `iframe`
28+
29+
> Note: Unsupported tags will not be rendered
4530
4631
## Why this package?
4732

4833
This package is designed with simplicity in mind. Flutter currently does not support rendering of web content
4934
into the widget tree. This package is designed to be a reasonable alternative for rendering static web content
50-
until official support is added.
35+
until official support is added.
36+
37+
## Example Usage:
38+
39+
Html(
40+
data: """
41+
<div>
42+
<h1>Demo Page</h1>
43+
<p>This is a fantastic nonexistent product that you should buy!</p>
44+
<h2>Pricing</h2>
45+
<p>Lorem ipsum <b>dolor</b> sit amet.</p>
46+
<h2>The Team</h2>
47+
<p>There isn't <i>really</i> a team...</p>
48+
<h2>Installation</h2>
49+
<p>You <u>cannot</u> install a nonexistent product!</p>
50+
</div>
51+
""",
52+
//Optional parameters:
53+
padding: EdgeInsets.all(8.0),
54+
backgroundColor: Colors.white70,
55+
defaultTextStyle: TextStyle(color: Colors.black),
56+
)

example/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ void main() {
2121
//Optional parameters:
2222
padding: EdgeInsets.all(8.0),
2323
backgroundColor: Colors.white70,
24+
defaultTextStyle: TextStyle(color: Colors.black),
2425
),
2526
),
2627
),

lib/flutter_html.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ import 'package:flutter/material.dart';
44
import 'package:flutter_html/html_parser.dart';
55

66
class Html extends StatelessWidget {
7-
Html({Key key, @required this.data, this.padding, this.backgroundColor})
7+
Html(
8+
{Key key,
9+
@required this.data,
10+
this.padding,
11+
this.backgroundColor,
12+
this.defaultTextStyle = const TextStyle(color: Colors.black)})
813
: super(key: key);
914

1015
final String data;
1116
final EdgeInsetsGeometry padding;
1217
final Color backgroundColor;
18+
final TextStyle defaultTextStyle;
1319

1420
@override
1521
Widget build(BuildContext context) {
@@ -18,7 +24,7 @@ class Html extends StatelessWidget {
1824
color: backgroundColor,
1925
child: Column(
2026
crossAxisAlignment: CrossAxisAlignment.start,
21-
children: HtmlParser.parse(data),
27+
children: HtmlParser(defaultTextStyle: defaultTextStyle).parse(data),
2228
),
2329
);
2430
}

0 commit comments

Comments
 (0)