【问题标题】:How to change the drop shadow (or shade) from a ModalBottomSheet in Flutter如何从 Flutter 中的 ModalBottomSheet 更改投影(或阴影)
【发布时间】:2019-11-08 11:59:52
【问题描述】:

ModalBottomSheet 会自动在底层屏幕上渲染阴影或阴影。

showModalBottomSheet 方法中将背景颜色设置为透明只会影响包含子窗口小部件的区域。
它不会删除模态下的阴影。

我可以移除或更改阴影的不透明度吗?

【问题讨论】:

  • 尝试将elevation参数设置为0
  • 您可以尝试覆盖主题数据中的bottom sheet theme

标签: flutter flutter-layout bottom-sheet


【解决方案1】:
showModalBottomSheet(
        barrierColor: Colors.white.withOpacity(0),
...

请注意,我使用的是属性“barrierColor”

【讨论】:

  • 编辑:添加了指出属性“barrierColor”的行
【解决方案2】:

如果你想增加或减少阴影你可以改变elevation:

showModalBottomSheet<void>(
    elevation: 2.0,
      context: context,
      builder: (BuildContext context) {

0表示没有阴影,使用2.0的倍数

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-18
    • 1970-01-01
    • 1970-01-01
    • 2018-12-02
    • 1970-01-01
    相关资源
    最近更新 更多