editix
editix

Reputation: 578

how to change image opacity within Image() widget - flutter

So am trying to change image opacity using the opacity property i found in Image() widget, this is a short code to be clear :

Padding(
            padding: EdgeInsets.all(10.0),
            child: Center(
              child: ClipRRect(
                borderRadius: BorderRadius.circular(15),
                child: Image(
                  image: NetworkImage(challengeImage),
                  fit: BoxFit.cover,
                  height: 150,
                  width: 350,
                  opacity: //not sure how to use
                ),
              ),
            ),
          ),

the image is a network image i retrieved from Firestore and am not sure what is the value i should put if its not double in order to apply opacity on the image. i thought to create a stack and insert asset image as a layer above my image and use the filter property but i would really like to know how the opacity can work with my code above, Thank you.

Upvotes: 2

Views: 2194

Answers (2)

Wissam Sbenaty
Wissam Sbenaty

Reputation: 153

Another solution : wrap the widget with Opacity Widget it accepts a double value in range [0,1] where 1 is fully displaying and 0 is not

Upvotes: 2

Md. Yeasin Sheikh
Md. Yeasin Sheikh

Reputation: 63649

You can use AlwaysStoppedAnimation or create an Animation<double>

Image(
  image: NetworkImage(""),
  opacity: AlwaysStoppedAnimation(.1),
),

Upvotes: 3

Related Questions