@@ -260,7 +260,8 @@ class HtmlRichTextParser extends StatelessWidget {
260
260
);
261
261
262
262
// ignore the top level "body"
263
- body.nodes.forEach ((dom.Node node) => _parseNode (node, parseContext));
263
+ body.nodes
264
+ .forEach ((dom.Node node) => _parseNode (node, parseContext, context));
264
265
// _parseNode(body, parseContext);
265
266
266
267
// filter out empty widgets
@@ -297,7 +298,8 @@ class HtmlRichTextParser extends StatelessWidget {
297
298
// function can add child nodes to the parent if it should
298
299
//
299
300
// each iteration creates a new parseContext as a copy of the previous one if it needs to
300
- void _parseNode (dom.Node node, ParseContext parseContext) {
301
+ void _parseNode (
302
+ dom.Node node, ParseContext parseContext, BuildContext buildContext) {
301
303
// TEXT ONLY NODES
302
304
// a text only node is a child of a tag with no inner html
303
305
if (node is dom.Text ) {
@@ -619,9 +621,27 @@ class HtmlRichTextParser extends StatelessWidget {
619
621
if (node.attributes['src' ] != null ) {
620
622
if (node.attributes['src' ].startsWith ("data:image" ) &&
621
623
node.attributes['src' ].contains ("base64," )) {
624
+ precacheImage (
625
+ MemoryImage (
626
+ base64.decode (
627
+ node.attributes['src' ].split ("base64," )[1 ].trim (),
628
+ ),
629
+ ),
630
+ buildContext,
631
+ onError: (_, stacktrace) {
632
+ print (stacktrace);
633
+ },
634
+ );
622
635
parseContext.rootWidgetList.add (Image .memory (base64.decode (
623
636
node.attributes['src' ].split ("base64," )[1 ].trim ())));
624
637
} else {
638
+ precacheImage (
639
+ NetworkImage (node.attributes['src' ]),
640
+ buildContext,
641
+ onError: (_, stacktrace) {
642
+ print (stacktrace);
643
+ },
644
+ );
625
645
parseContext.rootWidgetList
626
646
.add (Image .network (node.attributes['src' ]));
627
647
}
@@ -738,7 +758,7 @@ class HtmlRichTextParser extends StatelessWidget {
738
758
}
739
759
740
760
node.nodes.forEach ((dom.Node childNode) {
741
- _parseNode (childNode, nextContext);
761
+ _parseNode (childNode, nextContext, buildContext );
742
762
});
743
763
}
744
764
}
0 commit comments