Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for rendering as RichText Widgets #37

Merged
merged 6 commits into from
Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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