![Flutter实战入门](https://wfqqreader-1252317822.image.myqcloud.com/cover/55/32436055/b_32436055.jpg)
上QQ阅读APP看书,第一时间看更新
3.1.6 容器类组件(Row和Column)
Row和Column组件是最常用的容器类组件,可以控制多个子控件,Row是水平方向,Column是垂直方向,主要属性参见表3-9。
表3-9 Row和Column属性
![](https://epubservercos.yuewen.com/E5359F/17517093106688906/epubprivate/OEBPS/Images/b3-9-i.jpg?sign=1738954597-bSkGwBrKaqS68Js2yEHkcLUwrU1FXUEC-0-6860bf9fe3d929fc2136e405f930cc14)
有3个Container子控件分别为1、2、3,子控件平均分布在Row内,代码如下:
Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ Container( width: 50, height: 30, decoration: BoxDecoration( border: Border.all( color: Colors.red, width: 1, style: BorderStyle.solid)), child: new Text("1"), alignment: AlignmentDirectional.center, ), Container( width: 50, height: 30, decoration: BoxDecoration( border: Border.all( color: Colors.red, width: 1, style: BorderStyle.solid)), child: new Text("2"), alignment: AlignmentDirectional.center, ), Container( width: 50, height: 30, decoration: BoxDecoration( border: Border.all( color: Colors.red, width: 1, style: BorderStyle.solid)), child: new Text("3"), alignment: AlignmentDirectional.center, ), ], )
代码运行效果如图3-13所示。
![](https://epubservercos.yuewen.com/E5359F/17517093106688906/epubprivate/OEBPS/Images/t3-13-i.jpg?sign=1738954597-3H8QKk3uWuTlTBQUonBHmE0azcyAhccC-0-3383b0a7301351b2bfca7695ead6248b)
图3-13 Row效果
对齐方式属性参见表3-10。
表3-10 对齐方式属性
![](https://epubservercos.yuewen.com/E5359F/17517093106688906/epubprivate/OEBPS/Images/b3-10-i.jpg?sign=1738954597-SeQSdP3GYnz9sRzN4nRwDT1cfm7efJzN-0-013d16da71370e0f9896e29a92843616)