1

我有一个 figma 设计,我需要像这样设置盒子阴影。

Drop shadow
x 0, y : 1, B: 5, S: 0, #000000 30%

投影

4

2 回答 2

3

使用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),
      ),
    ],
  ),
);

截屏 在此处输入图像描述

在 DartPad 上试用完整代码

于 2021-05-06T23:40:43.043 回答
1

您可以使用 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(),
    );
  }
于 2021-05-06T23:37:24.170 回答