Flutter — How to give a background image opacity on a Container

--

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,
),
),
),
);

--

--

<Blake†Codez />
<Blake†Codez />

Written by <Blake†Codez />

I’m a Software Engineering student in Redding, Ca. Love all things Computer Science related, love for journalism, Jesus Christ, and team collaboration projects.

No responses yet