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

标签 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"),
                  )

              ),

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

screenshot

最佳答案

如果你用圆角包裹你的 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"),
           )
         ),
        ),

关于dart - 具有透明背景的 flutter 角半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50008737/

相关文章:

flutter - SingleChildScrollView不可滚动

android - 类型 'Null' 不是类型 'Function' 的子类型

flutter - 在flutter中从Firebase实时数据库检索数据时,有什么方法可以显示加载小部件的方法

ios - Flutter - 无法在 Android Studio 上构建 iOS 应用程序

flutter - 使 Flutter 中的 listView.builder 中的项目计数停止

firebase - Flutter Firestore甚至在提供orderby函数后仍以错误的顺序获取

Flutter:为什么 setState(( ) { }) 一次又一次地设置数据

ios - 使用 CodeMagic 部署时如何增加 Flutter IOS 应用程序的内部版本号

flutter - Flutter中位于回调​​函数前面的括号内的变量是否作为参数传递给这些回调函数?

flutter - 如果传递了渐变,则框装饰中的渐变或颜色