我做了很多行。现在,我要在这些行的顶部放置一个容器。我怎样才能做到这一点。我使用了堆栈小部件进行了尝试,但是它只是将所有东西都堆叠在一起,因此无法控制位置。
如何在一堆行的顶部绘制一个容器。
谢谢您的帮助。
答案 0 :(得分:1)
您可以检查以下代码,尽管您的询问有些混乱。您需要使用Positioned
并在顶部和左侧设置一些值。
Scaffold(
body: Stack(
children: [
Positioned(
top:0 ,
left: 0,
child: Container(
height: 100,
width: 100,
color: Colors.red,
),
),
Positioned(
top:100 ,
left: 0,
child: Container(
height: 100,
width: 100,
color: Colors.red,
child: Row(),
),
),
Positioned(
top:200 ,
left: 0,
child: Container(
height: 100,
width: 100,
color: Colors.red,
child: Row(),
),
),
Positioned(
top:300 ,
left: 0,
child: Container(
height: 100,
width: 100,
color: Colors.red,
child: Row(),
),
),
],
),
)