Skip to content
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

How to use ImageExtension ? #1409

Open
zxl777 opened this issue Jan 23, 2024 · 3 comments
Open

How to use ImageExtension ? #1409

zxl777 opened this issue Jan 23, 2024 · 3 comments
Labels

Comments

@zxl777
Copy link

zxl777 commented Jan 23, 2024

I previously added rounded corners to <img> tags in an older version of flutter_html, but how should I achieve the same effect with the new ImageExtension?

                    customRender: {
                      'img': (context, child) {
                        return ClipRRect(
                          borderRadius: BorderRadius.circular(5.0),
                          child: (context.tree as ImageContentElement).toWidget(context),
                        );
                      }
                    }
@azeunkn0wn
Copy link

azeunkn0wn commented May 4, 2024

Try this:

 ImageExtension(
     builder: (extensionContext) {
          final element = extensionContext.styledElement as ImageElement;
             
          return ClipRRect(
              borderRadius: BorderRadius.circular(5.0),                         
              child: Image.network(
                  element.src,
                ),
              );
            },
          ),

@leeparayno
Copy link

In current 3.0.0-beta.2 ImageElement is not defined for me. What is the current status of img tag?

@ilikerobots
Copy link

A bit hacky, but you can cast styledElement to dynamic:
final url = (extensionContext.styledElement as dynamic).src;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants