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

Add HTML Rendering #165

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 4 additions & 1 deletion lib/consts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ const Map<String, Map<String, List<ResponseBodyView>>>
kTypeText: {
kSubTypeDefaultViewOptions: kRawBodyViewOptions,
kSubTypeCss: kCodeRawBodyViewOptions,
kSubTypeHtml: kCodeRawBodyViewOptions,
kSubTypeHtml: kPreviewCodeRawBodyViewOptions,
kSubTypeJavascript: kCodeRawBodyViewOptions,
kSubTypeMarkdown: kCodeRawBodyViewOptions,
kSubTypeTextXml: kCodeRawBodyViewOptions,
Expand Down Expand Up @@ -483,6 +483,9 @@ const kImageError =
const kSvgError =
"There seems to be an issue rendering this SVG image. Please raise an issue in API Dash GitHub repo so that we can resolve it.";

const kHtmlError =
"There seems to be an issue rendering this HTML document. Please raise an issue in API Dash GitHub repo so that we can resolve it.";

const kPdfError =
"There seems to be an issue rendering this pdf. Please raise an issue in API Dash GitHub repo so that we can resolve it.";

Expand Down
12 changes: 12 additions & 0 deletions lib/widgets/previewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:printing/printing.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:vector_graphics_compiler/vector_graphics_compiler.dart';
import 'error_message.dart';
import 'uint8_audio_player.dart';
Expand Down Expand Up @@ -42,6 +43,17 @@ class _PreviewerState extends State<Previewer> {
// pass
}
}
if (widget.type == kTypeText && widget.subtype == kSubTypeHtml) {
try {
return SingleChildScrollView(
child: HtmlWidget(
widget.body,
),
);
} catch (e) {
return const ErrorMessage(message: kHtmlError);
}
}
if (widget.type == kTypeImage && widget.subtype == kSubTypeSvg) {
final String rawSvg = widget.body;
try {
Expand Down
Loading