Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to use placeholder in CachedNetworkImage?

I want to add a placeholder of a progress bar while image is loading but for some reason it does not work.

My code

CachedNetworkImage(
  imageUrl: 'url',
  fit: BoxFit.cover,
  height: 100,
  width: 100,
  placeholder: CircularProgressIndicator(),
),

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use progressIndicatorBuilder when image is loading like this

progressIndicatorBuilder:
                          (context, url, downloadProgress) => Container(
                        decoration: const BoxDecoration(
                          shape: BoxShape.circle,
                          color: Colors.white,
                        ),
                      ),

or try this for placeholder

placeholder: (context, url) => new CircularProgressIndicator(),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading