@@ -15,7 +15,7 @@ import 'package:html/parser.dart' as htmlparser;
1515import 'package:webview_flutter/webview_flutter.dart' ;
1616
1717typedef OnTap = void Function (String url);
18- typedef CustomRender = Widget Function (
18+ typedef CustomRender = dynamic Function (
1919 RenderContext context,
2020 Widget parsedChild,
2121 Map <String , String > attributes,
@@ -243,27 +243,31 @@ class HtmlParser extends StatelessWidget {
243243 );
244244
245245 if (customRender? .containsKey (tree.name) ?? false ) {
246- return WidgetSpan (
247- child: ContainerSpan (
246+ final render = customRender[tree.name].call (
247+ newContext,
248+ ContainerSpan (
248249 newContext: newContext,
249250 style: tree.style,
250251 shrinkWrap: context.parser.shrinkWrap,
251- child: customRender[tree.name].call (
252- newContext,
253- ContainerSpan (
254- newContext: newContext,
255- style: tree.style,
256- shrinkWrap: context.parser.shrinkWrap,
257- children: tree.children
258- ? .map ((tree) => parseTree (newContext, tree))
259- ? .toList () ??
260- [],
261- ),
262- tree.attributes,
263- tree.element,
264- ),
252+ children: tree.children
253+ ? .map ((tree) => parseTree (newContext, tree))
254+ ? .toList () ??
255+ [],
265256 ),
257+ tree.attributes,
258+ tree.element,
266259 );
260+ assert (render is InlineSpan || render is Widget );
261+ return render is InlineSpan
262+ ? render
263+ : WidgetSpan (
264+ child: ContainerSpan (
265+ newContext: newContext,
266+ style: tree.style,
267+ shrinkWrap: context.parser.shrinkWrap,
268+ child: render,
269+ ),
270+ );
267271 }
268272
269273 //Return the correct InlineSpan based on the element type.
0 commit comments