Flutter — How to give a background image opacity on a Container
Dec 16, 2022
When dealing with background images on a container, there might be a need to add some opacity for different UI / UX designs.
Inside the DecorationImage class you can use the colorFilter property which will allow for an opacity. ColorFilter.mode accepts Colors.white.withOpacity(0.8), and BlendMode.dtsATop.
Container(
width: 300.0,
height: 500.0,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
"https://images.unsplash.com/photo-1579202673506-ca3ce28943ef"),
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(
Colors.white.withOpacity(0.8),
BlendMode.dstATop,
),
),
),
);