![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=1738868033-yf04OIMzjYeNsW5g5Gn1g3MasAZU9W0v-0-d022d2acfd4f79d7755f3f9b025c6d9e)
宽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=1738868033-Gu9oeH2K6w3FVf5PZQySPiXyCw8Tgbrx-0-71473a2e0fe0c9dd02380ced48514400)
图3-12 Container组件效果