有没有办法在使用showModalBottomSheet时更改覆盖背景色?

现在的 colored颜色 总是灰色,但是我想使用不同的 colored颜色 ,比如绿色,如下所示.

changing color

以下是演示中使用的代码供参考

        showModalBottomSheet<void>(context: context, builder: (BuildContext context) {
          return Container(
            child: Padding(
              padding: const EdgeInsets.all(32.0),
              child: Text('This is the modal bottom sheet. Tap anywhere to dismiss.',
                textAlign: TextAlign.center,
                style: TextStyle(
                  color: Theme.of(context).accentColor,
                  fontSize: 24.0
                )
              )
            )
          );
        });

推荐答案

新的Flutter 更新允许您更改showModalBottomSheet()中的barrierColor

showModalBottomSheet(
      barrierColor: Colors.yellow.withOpacity(0.5),

Dart相关问答推荐

构造函数:将预处理的参数存储在传递给最终字段的辅助变量中

如何扩展 Dart 套接字 BroadcastStream 缓冲区大小为 1024 字节?

Const 构造函数不适用于 Dart 并显示 id 为 0

切换到可靠的零安全后简单分配中的可空性不匹配

如何在flutter中使用rootBundle加载图片?

如何根据 Select 的选项卡更改样式?

如何签署 Flutter 的应用程序

如何在 Flutter CustomPainter 中使用Bezier Curves绘制形状

如何在dart中的多个文件中编写多个单元测试?

Flutter 使用什么 colored颜色 系统,为什么我们使用 `const Color` 而不是 `new Color`

Firebase 手机身份验证Flutter crash崩溃

Flutter:出现键盘时背景图像正在挤压

在 Dart 中将 List 转换为字符串?

如何在 Angular.Dart 中以编程方式添加组件?

为什么不推荐使用 context2d.backingStorePixelRatio?

如何构建具有多个视图的复杂 Web UI 应用程序?

从 Dart Map 中删除选定的键

导出两个具有相同类名的库

`FutureOr` 的目的是什么?

如何删除dart列表中的重复项? list.distinct()?