一、介紹
container類似前端中的 div,語法:container(child:組件),意思就是容器,里面只能放一個(gè)組件。
二、屬性:
1. alignment對(duì)齊方式:
topCenter:頂部居中對(duì)齊
topLeft:頂部左對(duì)齊
topRight:頂部右對(duì)齊
center:水平垂直居中對(duì)齊
centerLeft:垂直居中水平居左對(duì)齊
centerRight:垂直居中水平居右對(duì)齊
bottomCenter 底部居中對(duì)齊
bottomLeft:底部居左對(duì)齊
bottomRight:底部居右對(duì)齊
2.decoration裝飾:
color顏色?
語法??color: Colors.blue [顏色為藍(lán)色]
border邊框
語法??border: Border.all(color: Colors.red,width: 2.0) [全部邊框顏色為紅色,粗細(xì)為2]
margin 外邊距
?margin 屬性是表示 Container 與外部其他組件的距離。? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 語法? margin:EdgeInsets.all(20.0) [上下左右邊距為20]
padding內(nèi)邊距
padding 就 是 Container 的 內(nèi) 邊 距 , 指Container 邊緣與 Child 之間的距離? ? ? ? ? 語法? padding: EdgeInsets.all(10.0)?[上下左右內(nèi)邊距為10]
transform變換,可以讓container旋轉(zhuǎn)等等
語法? transform: Matrix4.rotationZ(0.2)
width、height 寬、高
語法? width:120.0, height: 30.0 [容器寬120,高30]
child 容器子元素
語法 child:Text("你好")[容器的子元素為“你好”的文本,child后邊也可以跟Row和Column,但只能跟一個(gè)哦;]