-
-
Notifications
You must be signed in to change notification settings - Fork 911
Added support to skip custom render-er if is null #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
These changes allow skipping the custom render-er and using back the default render-er in some cases, by returning a null value or not returning any value from the function "customRender".
Could you give an example where this is useful? |
Very useful feature. This is helpful for example when changing only elements with specific attributes. Currently it's only possible to add a custom renderer for whole tags. But with this change it could be possible to check specific attributes and only change the rendering when necessary. An other example is an iframe. When it's a YouTube url I would like to show a custom YouTube player, and for other urls the normal WebView. |
@DFelten Thank you! Indeed very clear clarification!
Providing that there is some html I need to parse,
In current version of "flutter_html", setting the "customRender" like this,
it will stop handling "simple link" or "image inside link" with default render-er, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great idea and almost correct but (perhaps due to upstream changes?) your code does not build. Extremely easy fix though as you just need to use child: customRenderForElement,
.
lib/html_parser.dart
Outdated
newContext: newContext, | ||
style: tree.style, | ||
shrinkWrap: context.parser.shrinkWrap, | ||
child: builder, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect. It needs to be
child: customRenderForElement,
@erickok I believe that the changes you requested have been made, and things look good to me, but I just want to make sure you are fine with it as well before I merge |
Yes, I applied them to this PR. I am using this in production. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@erickok it looks like you have to resolve the change request before I can merge |
@ryan-berger done |
These changes allow skipping the custom render-er and using back the default render-er in some cases,
by returning a null value or not returning any value from the function "customRender".