Skip to content

Commit 86a9bac

Browse files
committed
Merge remote-tracking branch 'tneotia/feature/modularization' into feature/release-300-alpha2
2 parents 7486430 + 6f09ffa commit 86a9bac

Some content is hidden

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

74 files changed

+2410
-1491
lines changed

README.md

Lines changed: 153 additions & 282 deletions
Large diffs are not rendered by default.

example/lib/main.dart

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_html/flutter_html.dart';
3+
import 'package:flutter_html_all/flutter_html_all.dart';
34
import 'package:flutter_math_fork/flutter_math.dart';
45

56
void main() => runApp(new MyApp());
@@ -268,18 +269,14 @@ class _MyHomePageState extends State<MyHomePage> {
268269
),
269270
'h5': Style(maxLines: 2, textOverflow: TextOverflow.ellipsis),
270271
},
271-
tagsList: Html.tags..addAll(["tex", "bird", "flutter"]),
272+
tagsList: Html.tags..addAll(['tex', 'bird', 'flutter']),
272273
customRenders: {
273274
tagMatcher("tex"): CustomRender.widget(widget: (context, buildChildren) => Math.tex(
274275
context.tree.element?.innerHtml ?? '',
275276
mathStyle: MathStyle.display,
276277
textStyle: context.style.generateTextStyle(),
277278
onErrorFallback: (FlutterMathException e) {
278-
if (context.parser.onMathError != null) {
279-
return context.parser.onMathError!.call(context.tree.element?.innerHtml ?? '', e.message, e.messageWithType);
280-
} else {
281-
return Text(e.message);
282-
}
279+
return Text(e.message);
283280
},
284281
)),
285282
tagMatcher("bird"): CustomRender.inlineSpan(inlineSpan: (context, buildChildren) => TextSpan(text: "🐦")),
@@ -292,28 +289,34 @@ class _MyHomePageState extends State<MyHomePage> {
292289
)),
293290
tagMatcher("table"): CustomRender.widget(widget: (context, buildChildren) => SingleChildScrollView(
294291
scrollDirection: Axis.horizontal,
295-
child: (context.tree as TableLayoutElement).toWidget(context),
292+
child: tableRender.call().widget!.call(context, buildChildren),
296293
)),
297-
},
298-
customImageRenders: {
299-
networkSourceMatcher(domains: ["flutter.dev"]):
300-
(context, attributes, element) {
301-
return FlutterLogo(size: 36);
302-
},
303-
networkSourceMatcher(domains: ["mydomain.com"]):
304-
networkImageRender(
294+
audioMatcher(): audioRender(),
295+
iframeMatcher(): iframeRender(),
296+
mathMatcher(): mathRender(onMathError: (error, exception, exceptionWithType) {
297+
print(exception);
298+
return Text(exception);
299+
}),
300+
svgTagMatcher(): svgTagRender(),
301+
svgDataUriMatcher(): svgDataImageRender(),
302+
svgAssetUriMatcher(): svgAssetImageRender(),
303+
svgNetworkSourceMatcher(): svgNetworkImageRender(),
304+
networkSourceMatcher(domains: ["flutter.dev"]): CustomRender.widget(
305+
widget: (context, buildChildren) {
306+
return FlutterLogo(size: 36);
307+
}),
308+
networkSourceMatcher(domains: ["mydomain.com"]): networkImageRender(
305309
headers: {"Custom-Header": "some-value"},
306310
altWidget: (alt) => Text(alt ?? ""),
307311
loadingWidget: () => Text("Loading..."),
308312
),
309313
// On relative paths starting with /wiki, prefix with a base url
310-
(attr, _) =>
311-
attr["src"] != null && attr["src"]!.startsWith("/wiki"):
312-
networkImageRender(
313-
mapUrl: (url) => "https://upload.wikimedia.org" + url!),
314+
(context) => context.tree.element?.attributes["src"] != null
315+
&& context.tree.element!.attributes["src"]!.startsWith("/wiki"):
316+
networkImageRender(mapUrl: (url) => "https://upload.wikimedia.org" + url!),
314317
// Custom placeholder image for broken links
315-
networkSourceMatcher():
316-
networkImageRender(altWidget: (_) => FlutterLogo()),
318+
networkSourceMatcher(): networkImageRender(altWidget: (_) => FlutterLogo()),
319+
videoMatcher(): videoRender(),
317320
},
318321
onLinkTap: (url, _, __, ___) {
319322
print("Opening $url...");
@@ -336,3 +339,9 @@ class _MyHomePageState extends State<MyHomePage> {
336339
);
337340
}
338341
}
342+
343+
CustomRenderMatcher texMatcher() => (context) => context.tree.element?.localName == 'tex';
344+
345+
CustomRenderMatcher birdMatcher() => (context) => context.tree.element?.localName == 'bird';
346+
347+
CustomRenderMatcher flutterMatcher() => (context) => context.tree.element?.localName == 'flutter';

example/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ environment:
99
dependencies:
1010
flutter_html:
1111
path: ..
12+
flutter_html_all:
13+
path: ../packages/flutter_html_all
1214
flutter:
1315
sdk: flutter
1416

0 commit comments

Comments
 (0)