[英]How to make containers start from the same position in flutter
Iam trying to create a figure like this using containers in flutter我正在尝试使用 flutter 中的容器创建这样的图形
I wrote the following code.我写了以下代码。
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(width: 5, height: 10, color: Colors.green),
Container(width: 5, height: 15, color: Colors.green),
Container(width: 5, height: 20, color: Colors.green),
Container(width: 5, height: 25, color: Colors.green),
Container(width: 5, height: 30, color: Colors.green),
],
),
I get the follwing output.我得到以下 output。
How to I make all the containers to start from the same level.如何使所有容器从同一级别开始。
Thank You.谢谢你。
Add crossAxisAlignment: CrossAxisAlignment.end
to your Row
将
crossAxisAlignment: CrossAxisAlignment.end
添加到您的Row
Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(width: 5, height: 10, color: Colors.green),
Container(width: 5, height: 15, color: Colors.green),
Container(width: 5, height: 20, color: Colors.green),
Container(width: 5, height: 25, color: Colors.green),
Container(width: 5, height: 30, color: Colors.green),
],
),
Use this code
使用此代码
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Container(width: 5, height: 10, color: Colors.green),
Container(width: 5, height: 15, color: Colors.green),
Container(width: 5, height: 20, color: Colors.green),
Container(width: 5, height: 25, color: Colors.green),
Container(width: 5, height: 30, color: Colors.green),
],
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.