[英]Flutter Container unwanted top and bottom padding
I created a Container with red color as background, and another one with white color as its child.我创建了一个以红色为背景的容器,另一个以白色为子级的容器。 I think the red one will be fully covered by the white one.我认为红色的会被白色的完全覆盖。 Instead, I see two red lines on top and bottom of the container.相反,我在容器的顶部和底部看到两条红线。 Its like the Container has top and bottom padding, and I can't remove it.它就像容器有顶部和底部填充,我不能删除它。
How to remove it (the top and bottom padding?) so that the white fully cover the red one?如何删除它(顶部和底部填充?)以便白色完全覆盖红色?
The red line shows like the container has top and bottom padding红线表示容器具有顶部和底部填充
update: Just tested it on a new project, and it shows perfectly, no padding.更新:刚刚在一个新项目上进行了测试,它显示完美,没有填充。 Any idea what causing this?知道是什么原因造成的吗?
class Test extends StatefulWidget {
Test(Object args);
@override
State<StatefulWidget> createState() {
return ContainerTest();
}
}
class ContainerTest extends State<Test>{
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Container(
color: Colors.white,
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("some text"),
),
Container(
width: 200,
height: 200,
color: Colors.red,
child: Container(
color: Colors.white,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("some text"),
),
],
),
),
);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.