Skip to content

Would be good to have example how to use FadeInImage #7

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
FastNinja opened this issue Jan 1, 2018 · 4 comments
Closed

Would be good to have example how to use FadeInImage #7

FastNinja opened this issue Jan 1, 2018 · 4 comments

Comments

@FastNinja
Copy link

just at the moment trying to read source code of flutter to figure out what is the exact usage...
once I figure it out - will update the issue.

@renefloor
Copy link
Contributor

The doc of FadeInImage is pretty easy and straightforward.

return new FadeInImage(
  // here `bytes` is a Uint8List containing the bytes for the in-memory image
  placeholder: new MemoryImage(bytes),
  image: new NetworkImage('https://backend.example.com/image.png'),
);

Just use CachedNetworkImageProvider for 'image' and for example an assetimage for 'placeholder'.

Probably going to remove it from the readme in the next version. It is also mentioned in the changelog.

@FastNinja
Copy link
Author

@renefloor this is the working example. Notice the AssertImage usage - as usually your placeholder is some static image..

 child: new FadeInImage(
                            
                            placeholder:
                                new AssetImage("images/placeholder.png"),
                            image: new CachedNetworkImageProvider(imageUrl),
                          ))))

by the way - all worked with new version. Awesome work @renefloor !

@renefloor
Copy link
Contributor

Yes indeed, an AssetImage would be a good choice, or the MemoryImage in my example. A MemoryImage shows even faster (so no flicker), but you have to load it yourself first.

@renefloor
Copy link
Contributor

@FastNinja because I also wanted some way to show an error I started working on a widget that holds a placeholder and an error widget. Would like to hear your opinion on it. It is still a work in progress, but I already published an alpha.
https://pub.dartlang.org/packages/cached_network_image/versions/0.3.0-alpha

@expilu expilu mentioned this issue Jul 23, 2020
2 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants