BoxShadow之flutter与css对应关系

2,987 阅读1分钟

BoxShadow之flutter与css对应关系

Css(box-shadow) Flutter(boxShadow)
offset 头两个length值 offset:Offset(x,y)
blur-radius 第三个length值 blurRadius:length
spread-radius 第四个length值 spreadRadius:length
color 最后一个color值 color:Color.xxxx
background:rgba(255,255,255,1);
box-shadow:0px 3px 12px 0px rgba(211,215,219,0.5);
Container(
  decoration: BoxDecoration(
    color: Color.fromRGBO(255,255,255,1), // 注意,这里必须设置背景颜色,不然效果不对
    boxShadow: [
    	BoxShadow(
        offset: Offset(0, 3),
        blurRadius: 12,
        spreadRadius: 0),
      	color: Color.fromRGBO(211, 215, 219, 0.5),
    ]),
)