Flutter - Container BoxShadow disappears on scroll in a ListView
This other answer is for those who need to continue with Container
:
Container(
decoration: BoxDecoration(
shape: BoxShape.circle, // BoxShape.circle or BoxShape.retangle
//color: const Color(0xFF66BB6A),
boxShadow: [BoxShadow(
color: Colors.grey,
blurRadius: 5.0,
),]
),
child: ...
),
I was trying to reproduce the issue, and I noticed that you didn't put any margin on your Container. Most likely the other items in your ListView
are covering up your manually drawn shadow because it's being drawn outside the bounds of your Container
.
I would recommend that you use a Card
instead of a container. You can get a natural-looking material shadow using the elevation
constructor argument. Cards come with some built-in margin, and you can add more by enclosing it in a Container
if you want. This will give you enough space for the shadow to be visible. You can control the color of the Card
with the color
constructor argument.
The corners of a Card
are slightly rounded. If you don't want rounded corners, you're going to be going off spec from Material design, but you could try enclosing a Material
with a type
of MaterialType.canvas
inside a Container
.