new_user
new_user

Reputation: 11

Adjust the brightness of images in flutter

Does anyone know how to adjust the brightness of an image asset in flutter? I currently have a background image and I wanted to add some brightness to the image for now. Could I get any assistance?

 Container(
              decoration: BoxDecoration(
                image: DecorationImage(
                    image: AssetImage(
                      'assets/images/image.png',
                    ),
                    fit: BoxFit.cover),
              ),
            ),           

Upvotes: 1

Views: 2342

Answers (2)

Anand A L
Anand A L

Reputation: 177

If you want to configure in container you can use following method.

You add black in color property & can also configure brightness with opacity.

BoxDecoration(
  color: Colors.black,
  image: DecorationImage(
      image: AssetImage('assets/images/image.png'
      fit: BoxFit.cover,
      opacity: 0.5,
      alignment: Alignment.center),
)

Upvotes: 0

CopsOnRoad
CopsOnRoad

Reputation: 267664

enter image description here

enter image description here

Use a ColoredBox over your image in a Stack:

SizedBox(
  height: 200,
  child: Stack(
    fit: StackFit.expand,
    children: [
      Image.asset('chocolate_image', fit: BoxFit.cover),
      ColoredBox(
        color: Colors.black.withOpacity(0.5) // 0: Light, 1: Dark
      ),
    ],
  ),
)

You can also use this ColorFiltered answer for more customizations.

Upvotes: 2

Related Questions