flutter_html
flutter_html copied to clipboard
[QUESTION] migrate customRender to customRender on flutter_html v3
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 ?

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';
See migration guide: https://github.com/Sub6Resources/flutter_html/wiki/Migration-Guides#300