![Flutter实战入门](https://wfqqreader-1252317822.image.myqcloud.com/cover/55/32436055/b_32436055.jpg)
上QQ阅读APP看书,第一时间看更新
3.1.5 容器类组件(Container)
Container是最常用的容器类组件之一,主要属性参见表3-8。
表3-8 Container属性
![](https://epubservercos.yuewen.com/E5359F/17517093106688906/epubprivate/OEBPS/Images/b3-8-i.jpg?sign=1738955175-frQNuwPjMUOqyITnAU69BopxOPcTFILe-0-8b63e56f559ba690c4f2f7aeff030e87)
宽300、高100的Container,子组件是Text且居中显示,四周红色圆角边框,代码如下:
Container( width: 200, height: 100, padding: EdgeInsets.all(10), decoration: BoxDecoration( border: Border.all(color: Colors.red, width: 1, style: BorderStyle.solid), borderRadius: BorderRadius.all(Radius.circular(10))), child: new Text("子控件"), alignment: AlignmentDirectional.center, )
运行效果如图3-12所示。
![](https://epubservercos.yuewen.com/E5359F/17517093106688906/epubprivate/OEBPS/Images/t3-12-i.jpg?sign=1738955175-4f1flijv6cuzhcuEpds0cjEFCPYZFB2B-0-117275fe55052a1f49aa7328ab1e805f)
图3-12 Container组件效果