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

Change opacity of image in CachedNetworkImage Flutter

Hello I have multiple images.

I want change the opacity of the image with the imageUrl.

My goal is that when user click on a image, it change his opacity.

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

My question is how to change the opacity while keeping the image ?

My CachedNetworkImage :

         CachedNetworkImage(
                imageUrl : _getImageUrl(),
                width: MediaQuery.of(context).size.width,
                height: MediaQuery.of(context).size.height,
                fit: BoxFit.cover,
                placeholder: (context, url) => const Center(child: CircularProgressIndicator()),
                errorWidget: (context, exception, stacktrace)
                {
                  return const Icon(Icons.warning);
                },
              )

>Solution :

You can wrap CachedNetworkImage with Opacity widget and provide opacity:x based on your need.

double _opacity =.3;
 ......

Opacity(
  opacity: _opacity.
  child:CachedNetworkImage(...)

More about Opacity.

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