我有一个 figma 设计,我需要像这样设置盒子阴影。
Drop shadow
x 0, y : 1, B: 5, S: 0, #000000 30%
使用Container
小部件并boxShadow
从其属性设置decoration
属性。
代码示例
Container(
height: 75,
width: 150,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
offset: Offset(0, 1),
blurRadius: 5,
color: Colors.black.withOpacity(0.3),
),
],
),
);
您可以使用 Container 和 BoxDecoration
Container(
padding: EdgeInsets.symmetric(vertical: 1, horizontal: 8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
offset: Offset(0, 1),
blurRadius: 5,
spreadRadius: 0,
)
],
),
child: Container(),
);
}