Sub6Resources / flutter_html

A Flutter widget for rendering static html as Flutter widgets (Will render over 80 different html tags!)
https://pub.dev/packages/flutter_html
MIT License
1.8k stars 875 forks source link

[BUG] customRender not working with custom html tags #1109

Closed TentacleSama4254 closed 1 year ago

TentacleSama4254 commented 2 years ago

As stated in the example code I tried to run

Widget html = Html(
  data: """
  <h3>Display bird element and flutter element <bird></bird></h3>
  <flutter></flutter>
  <flutter horizontal></flutter>
  """,
  customRender: {
      "bird": (RenderContext context, Widget child) {
        return TextSpan(text: "🐦");
      },
      "flutter": (RenderContext context, Widget child) {
        return FlutterLogo(
          style: (context.tree.element!.attributes['horizontal'] != null)
              ? FlutterLogoStyle.horizontal
              : FlutterLogoStyle.markOnly,
          textColor: context.style.color!,
          size: context.style.fontSize!.size! * 5,
        );
      },
    },
  tagsList: Html.tags..addAll(["bird", "flutter"]),
);

But there is no output. Works with already existing tags. Do the new versions not support this or am I doing anything wrong?

Sub6Resources commented 1 year ago

3.0.0 has changed quite a bit with custom rendering. See the 3.0.0 Migration Guide