dart - 具有透明背景的 flutter 角半径

下面是我的代码,我希望渲染一个具有透明背景的圆角容器。

return new Container(
                //padding: const EdgeInsets.all(32.0),
                height: 800.0,
                //color: const Color(0xffDC1C17),
                //color: const Color(0xffFFAB91),
                decoration: new BoxDecoration(
                  color: Colors.green, //new Color.fromRGBO(255, 0, 0, 0.0),
                  borderRadius: new BorderRadius.only(
                    topLeft:  const  Radius.circular(40.0),
                    topRight: const  Radius.circular(40.0))
                ),
                child:  new Container(
                    decoration: new BoxDecoration(
                        color: Colors.blue,
                        borderRadius: new BorderRadius.only(
                            topLeft:  const  Radius.circular(40.0),
                            topRight: const  Radius.circular(40.0))
                    ),
                  child: new Center(
                    child: new Text("Hi modal sheet"),
                  )

              ),

然而,这就是它渲染的内容,它会渲染一个具有圆角半径的白色容器(预期为透明)。有什么帮助吗?

最佳答案

如果你用圆角包裹你的 Container 并且背景颜色设置为 Colors.transparent 我认为这就是你想要的。如果您使用的是 Scaffold,则默认背景颜色为白色。如果能达到你想要的效果,请将其更改为 Colors.transparent

        new Container(
          height: 300.0,
          color: Colors.transparent,
          child: new Container(
            decoration: new BoxDecoration(
              color: Colors.green,
              borderRadius: new BorderRadius.only(
                topLeft: const Radius.circular(40.0),
                topRight: const Radius.circular(40.0),
              )
            ),
            child: new Center(
            child: new Text("Hi modal sheet"),
           )
         ),
        ),

https://stackoverflow.com/questions/50008737/

相关文章:

flutter - 在 Flutter 中延迟一段时间后如何运行代码?

flutter - 有多个英雄在子树中共享相同的标签

functional-programming - Dart:映射列表(list.map)

flutter - 如何在 flutter 中为文本加下划线

git - flutter 安装期间的libusbmuxd版本错误

dart - Flutter 移除所有路由

flutter - 更改项目名称

flutter - 如何在 flutter 中使用进度指示器?

flutter - InkWell 没有显示涟漪效应

dart - 如何将非字符串数据传递给 Flutter 中的命名路由?