Skip to content

Commit

Permalink
Merge pull request #37 from jeffmikels/jeffmikels
Browse files Browse the repository at this point in the history
Added support for rendering as RichText Widgets
  • Loading branch information
Sub6Resources authored Feb 1, 2019
2 parents 4b8b108 + 5a26bc7 commit c4220df
Show file tree
Hide file tree
Showing 3 changed files with 778 additions and 16 deletions.
27 changes: 17 additions & 10 deletions lib/flutter_html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ class Html extends StatelessWidget {
@required this.data,
this.padding,
this.backgroundColor,
this.defaultTextStyle = const TextStyle(color: Colors.black),
this.defaultTextStyle,
this.onLinkTap,
this.renderNewlines = false,
this.customRender,
this.useRichText = false,
}) : super(key: key);

final String data;
Expand All @@ -21,6 +22,7 @@ class Html extends StatelessWidget {
final TextStyle defaultTextStyle;
final OnLinkTap onLinkTap;
final bool renderNewlines;
final bool useRichText;

/// Either return a custom widget for specific node types or return null to
/// fallback to the default rendering.
Expand All @@ -35,15 +37,20 @@ class Html extends StatelessWidget {
color: backgroundColor,
width: width,
child: DefaultTextStyle.merge(
style: defaultTextStyle,
child: Wrap(
alignment: WrapAlignment.start,
children: HtmlParser(
width: width,
onLinkTap: onLinkTap,
renderNewlines: renderNewlines,
customRender: customRender,
).parse(data),
style: defaultTextStyle ?? DefaultTextStyle.of(context).style,
child: (useRichText)
? HtmlRichTextParser(
width: width,
onLinkTap: onLinkTap,
renderNewlines: renderNewlines,
html: data,
)
: HtmlOldParser(
width: width,
onLinkTap: onLinkTap,
renderNewlines: renderNewlines,
customRender: customRender,
html: data,
),
),
);
Expand Down
Loading

0 comments on commit c4220df

Please sign in to comment.