使子窗口小部件对其父窗口透明

问题描述 投票:0回答:1

我尝试使用具有不透明度的深色背景进行相机预览,并且在中间部分具有卡片区域,其具有透明背景。它看起来像是在深色背景的移动设备中显示Dialog,但对话框在深色背景下具有透明背景。

我已经完成了使用列和行小部件,例如:

Column(
  children : <Widget>[
    Expanded(
      child: Container(
        color: Colors.Black54
      )
    ),

    Row(
      children : <Widget>[
        Expanded(
          child: Container(
            color: Colors.Black54
          )
        ),

        CardWidget(
          width: cardWidth,
          height: cardHeight,
          Color: Colors.Transparent
        ),

        Expanded(
          child: Container(
             color: Colors.Black54
          )
        ),
      ]
    ),

    Expanded(
      child: Container(
        color: Colors.Black54
      )
    ),

  ]
)

但我想知道有一个简单的方法,如:

 Container(
  color: Colors.Black54,
  child: center(
    child: CardWidget(
      width: cardWidth,
      height: cardHeight,
      background: Colors.Transparent
    )
  )
)

如果有其他方法可以像上面的代码一样简单,请告诉我。谢谢

dart flutter
1个回答
1
投票

你想做这样的事吗?

enter image description here

如果是,这是代码:

new Container(
      decoration: new BoxDecoration(
          border: Border(
            top: BorderSide(width: 300, color: Colors.grey[700]),
            left: BorderSide(width: 100, color: Colors.grey[700]),
            right: BorderSide(width: 100, color: Colors.grey[700]),
            bottom: BorderSide(width: 300, color: Colors.grey[700]),
          ),
          color: Colors.transparent),
    )
© www.soinside.com 2019 - 2024. All rights reserved.