flutter_html icon indicating copy to clipboard operation
flutter_html copied to clipboard

[QUESTION] migrate customRender to customRender on flutter_html v3

Open evaisse opened this issue 3 years ago • 1 comments

I have an old implementation of customRender which is below

        "li": (RenderContext context, widget) {
          context.style.markerContent = null; // Remove bullet point for list cause list-style: none is not supported
        },
        "center": (RenderContext context, widget) {
          context.style.textAlign = TextAlign.center;
        }

Basically, this code just alter the style passed to generated widget regarding is tag name. But trying to migrate to flutter_html:^3.0, I can find any way to do the same. How would you migrate old customRender parameters to the new customRenders in this case ?

cute-firefox

evaisse avatar Aug 03 '22 08:08 evaisse

Haven't tested it but this should give you the general idea.

return Html(
	data: data,
	tagsList: Html.tags..addAll(['li']),
	customRenders:
	{
		liMatcher(): CustomRender.widget(widget: (RenderContext context, buildChildren)
		{
                        context.style.markerContent = null;
			return Text('li replacement');
		}),
	}
);

CustomRenderMatcher liMatcher() => (context) => context.tree.element?.localName == 'li';

asmith20002 avatar Aug 05 '22 19:08 asmith20002

See migration guide: https://github.com/Sub6Resources/flutter_html/wiki/Migration-Guides#300

Sub6Resources avatar May 13 '23 18:05 Sub6Resources