Dart 使容器背景透明?
我有一个像这样的容器 它有一些背景色。我希望容器后面的列表应该是可见的。为容器编写的代码如下:Dart 使容器背景透明?,dart,flutter,flutter-layout,Dart,Flutter,Flutter Layout,我有一个像这样的容器 它有一些背景色。我希望容器后面的列表应该是可见的。为容器编写的代码如下: new Container( margin: EdgeInsets.fromLTRB(50.0, 10.0, 50.0, 10.0), width: _isTextFieldActive ? 150.0 : 80.0, height: 40.0, deco
new Container(
margin: EdgeInsets.fromLTRB(50.0, 10.0, 50.0, 10.0),
width: _isTextFieldActive ? 150.0 : 80.0,
height: 40.0,
decoration: new BoxDecoration(
color: Color(0xFF98DAFC),
borderRadius: new BorderRadius.only(
topLeft: Radius.circular(0.0),
topRight: Radius.circular(32.0),
bottomLeft: Radius.circular(0.0),
bottomRight: Radius.circular(32.0))),
alignment: Alignment.bottomCenter,
child: new Row(
children: <Widget>[
new Container(
width: 40.0,
height: 40.0,
child: new Checkbox(value: true)),
new Container(
width: 40.0,
height: 40.0,
decoration: new BoxDecoration(
color: Color(0xFFDEDEDE),
borderRadius:
new BorderRadius.circular(32.0)),
child: new IconButton(
icon: Icon(Icons.search),
);
}
},
))
],
),
),
新容器(
边距:LTRB(50.0,10.0,50.0,10.0)的边距集,
宽度:_isTextFieldActive?150.0:80.0,
身高:40.0,
装饰:新盒子装饰(
颜色:颜色(0xFF98DAFC),
borderRadius:仅限新的borderRadius(
左上:半径。圆形(0.0),
右上角:半径。圆形(32.0),
左下角:半径。圆形(0.0),
右下角:半径.圆形(32.0)),
对齐:对齐.bottomCenter,
孩子:新的一排(
儿童:[
新容器(
宽度:40.0,
身高:40.0,
子项:新建复选框(值:true)),
新容器(
宽度:40.0,
身高:40.0,
装饰:新盒子装饰(
颜色:颜色(0xFFDEDED),
边界半径:
新边界半径。圆形(32.0)),
孩子:新的图标按钮(
图标:图标(Icons.search),
);
}
},
))
],
),
),
因此,我希望容器没有背景色,并且容器后面的列表应该可见
如果我删除上面的代码,我得到的屏幕如下。
我不能100%确定这是不是真的,因为我现在无法测试它,但我认为问题可能是margin属性。如果我没弄错的话,你想把容器放在底部中间,底部填充10dp。我会这样做:
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.only(bottom: 10.0),
child: Container(
height: 40.0,
decoration: BoxDecoration(
color: Color(0xFF98DAFC),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(0.0),
topRight: Radius.circular(32.0),
bottomLeft: Radius.circular(0.0),
bottomRight: Radius.circular(32.0),
),
),
child: ...,
),
),
)
您确定这个背景是由您提供代码的容器绘制的吗?你能提供更多的上下文吗?@EliasProjahn是的,背景是由我给出代码的容器绘制的。检查后,我更新了问题。你把容器放在哪里?它在堆栈中吗?@EliasProjahn是的,容器在堆栈中。@EliasProjahn我用flex得到了它。感谢您的支持:)我使用了上述代码,但输出与第一幅图像相同。很抱歉:-(您可以尝试将容器包装在另一个具有透明背景的容器中。我尝试包装其他容器,但结果相同@EliasProjahn