[英]How to put widget in the center and top of two widgets?
I am designing a widget where, I want to put widget in the center of two rectangular container.我正在设计一个小部件,我想将小部件放在两个矩形容器的中心。 My idea is that when I click on it, center widget becomes visible.
我的想法是,当我单击它时,中心小部件变得可见。 It looks like this.
它看起来像这样。
What I wanted to do is that clicking on one grey container or both, this purple widget becomes visible, clicking again, it would disappear.我想要做的是单击一个灰色容器或两者,这个紫色小部件变得可见,再次单击它会消失。 This is my code below.
这是我下面的代码。
Stack(
alignment: Alignment.center,
children: [
Container(
width: 70,
height: 40,
color: Colors.indigo,
),
Container(
width: 100,
height: 70,
child: Column(
children: [
Container(
width: 100,
height: 30,
decoration: BoxDecoration(
color: Colors.grey,
),
),
SizedBox(height: 10,),
Container(
width: 100,
height: 30,
decoration: BoxDecoration(
color: Colors.grey,
),
),
],
),
),
],
),
However, with this the widget hides behind two widgets like this.但是,有了这个小部件隐藏在两个像这样的小部件后面。
Anybody can help me with its positioning?有人可以帮我定位吗?
Here is my answer.这是我的答案。
Stack(
alignment: Alignment.center,
children: [
Container(
width: 100,
height: 70,
child: Column(
children: [
Container(
width: 100,
height: 30,
decoration: BoxDecoration(
color: Colors.grey,
),
),
SizedBox(height: 10,),
Container(
width: 100,
height: 30,
decoration: BoxDecoration(
color: Colors.grey,
),
),
],
),
),
Container(
width: 70,
height: 40,
color: Colors.indigo,
),
],
),
Just replace the widgets只需更换小部件
Stack(
alignment: Alignment.center,
children: [
Container(
width: 100,
height: 70,
child: Column(
children: [
Container(
width: 100,
height: 30,
decoration: BoxDecoration(
color: Colors.grey,
),
),
SizedBox(height: 10,),
Container(
width: 100,
height: 30,
decoration: BoxDecoration(
color: Colors.grey,
),
),
Container(
width: 70,
height: 40,
color: Colors.indigo,
),
],
),
),
],
),
like stack ;)像堆栈;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.