Reputation: 11
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
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
Reputation: 267664
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