I'm trying to create a Row of containers that all have a BoxShadow. The shadows are quite large and therefore span into space that's outside of the parent, so I'm using clipBehavior: Clip.none on the parent.
The problem with this is that for each Container within the row it's shadow overlaps into the previous container. I've set some bold colors below to emphasize the issue. As you can see the right-hand side of the previous Container gets the shadow from the next.
Here's my code
return SingleChildScrollView(
clipBehavior: Clip.none,
scrollDirection: Axis.horizontal,
child: Row(
children: [
_ShadowedBox(),
_ShadowedBox(),
_ShadowedBox(),
],
),
);
class _ShadowedBox extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: 144,
child: Column(
children: [
SizedBox(
width: 144,
height: 144,
child: Container(
decoration: BoxDecoration(
color: Colors.grey,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(cardRadius),
boxShadow: [
BoxShadow(
offset: const Offset(0.0, 6.0),
blurRadius: 38.0,
spreadRadius: 0.0,
color: Colors.red,
),
BoxShadow(
offset: const Offset(0.0, 6.0),
blurRadius: 46.0,
spreadRadius: 0.0,
color: Colors.green,
),
BoxShadow(
offset: const Offset(0.0, 6.0),
blurRadius: 10.0,
spreadRadius: 0.0,
color: Colors.blue,
),
]
),
child: ClipRRect(
borderRadius: BorderRadius.circular(cardRadius),
child: Image.network("https://via.placeholder.com/400x400.png?text=Coming%20soon", fit: BoxFit.contain)
),
),
],
),
);
}
}
Can anyone suggest how to stop the shadow bleeding into the other containers while still being able to show the shadows not being clipped by the parent?


