Skip to content

Implement broken image placeholder #386

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

Closed
leeprobert opened this issue Aug 19, 2020 · 3 comments
Closed

Implement broken image placeholder #386

leeprobert opened this issue Aug 19, 2020 · 3 comments

Comments

@leeprobert
Copy link

I can see that you have a way to handle Image network exceptions, but it would be great if we could also define placeholders for broken images.

@DFelten
Copy link
Contributor

DFelten commented Aug 20, 2020

You could create a custom renderer for images and use there for example a CachedNetworkImage.

'img': (renderContext, child, attributes, _) => CachedNetworkImage(
  width: attributes['width'],
  placeholder: (context, url) => Container(),
  imageUrl: attributes['src'],
  errorWidget: (context, url, error) => Container(),
);

@amanokerim
Copy link

You could create a custom renderer for images and use there for example a CachedNetworkImage.

'img': (renderContext, child, attributes, _) => CachedNetworkImage(
  width: attributes['width'],
  placeholder: (context, url) => Container(),
  imageUrl: attributes['src'],
  errorWidget: (context, url, error) => Container(),
);

You forgot to parse to double width.

@erickok
Copy link
Contributor

erickok commented Feb 9, 2021

With the new image loading API (see README) you can do this:

networkSourceMatcher(): networkImageRender(altWidget: (_) => FlutterLogo()),

This will render the Flutter logo as a placeholder.

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

No branches or pull requests

4 participants