I need to create a shadow for container but the shadow color needs to be changed when spread.
Container(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 16),
margin: EdgeInsets.only(right: 3),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
spreadRadius: 12,
offset: Offset(0, 0),
color: Color(0xffEBEBEB),
// // color: Color(0xff1E1E1E),
// spreadRadius: 25,
blurRadius: 14,
//offset: Offset(0.0, 1),
)
]
),
height: double.infinity,
width: 0.5,
),
I tried many ways but nothing works.
2
Answers
If you want to add shadow, you have to add decoration as a parent of column widget. not as a separator.
Simple way you can wrap your column with
Material
and set theelevation
Another option is by setting the shadow manually. Setting the
offset
for specific position of shadow:offset(-12,0)
will placed the shadow only on the left side.Result:
or you can customize the position of shadow.
Offset(-x,0)
Offset(-x,-y)
Offset(x,-y)
Offset(-x,y)
Try demo here: https://dartpad.dev/?id=ebad3affe59160e1070642da95d1ab69
Try reducing the spread and increase the blur:
You probably have to adjust the color since I could barely see the shadow while testing.