【问题标题】:How to remove elevation shadow from one side without removing elevation itself in flutter from Card or Material widget?如何从一侧移除高程阴影而不从卡片或材质小部件中移除高程本身?
【发布时间】:2020-12-31 11:28:52
【问题描述】:

如何移除 Card 或 Material 小部件内的顶部高程阴影。

我将 Material 小部件用于容器,并为高程指定了一个值。它从四面八方反射到我的容器中。但我只想要左侧、底部和右侧的高程阴影。我怎样才能得到它或删除顶部立面阴影。 Material 或 Card Widget 中的示例将很有用。

Material(
  elevation: 3,
  child: Container(
    height: 100,
    width: 300,
  ),
)

【问题讨论】:

  • 添加一些代码
  • 您可以通过为容器提供阴影来实现此目的
  • 我试图使用 Material 或 Card 小部件来实现它。
  • 这里添加一些代码
  • Material(elevation: 3, child: Container(height: 100, width: 100, ), ) 从顶部移除高程会有帮助。

标签: flutter dart elevation card


【解决方案1】:

为此,您只需通过增加 offset 属性的 y 轴shadow 降低一点,如下所示:

Container(
  height: 100.0,
  width: 300.0,
    decoration: BoxDecoration(
      borderRadius: BorderRadius.circular(20.0),
      color: Colors.white,
      boxShadow: [
        BoxShadow(
          spreadRadius: 2,
          blurRadius: 3,
          offset: Offset(0, 6),
          color: Colors.black38
        )
      ]
    ),
  ),

这是输出:

【讨论】:

    猜你喜欢
    • 2018-05-23
    • 2021-06-10
    • 2017-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-25
    • 2017-09-08
    相关资源
    最近更新 更多