child: Text(“xmiaoshen”,style: TextStyle(fontWeight: FontWeight.bold,fontSize: 18.0),),
),
内边距
内边距 (padding): Container 内部widget分别到四边距离.
Container(
width: 200.0,
height: 200.0,
color: Colors.blue,
padding: EdgeInsets.only(top: 10.0,left: 10.0),
alignment: Alignment.topLeft,
child: Text(“xmiaoshen”,style: TextStyle(fontWeight: FontWeight.bold,fontSize: 18.0),),
)
子widget宽高超过或者等于父容器时,内边距属性padding依然有效
Container(
width: 200.0,
height: 200.0,
color: Colors.blue,
padding: EdgeInsets.all(18.0),
alignment: Alignment.topLeft,
child: Container(width: 200.0,height: 200.0,color: Colors.black45,),
)
Container(
width: 200.0,
height: 200.0,
color: Colors.blue,
padding: EdgeInsets.all(18.0),
alignment: Alignment.topLeft,
child: Container(width: 300.0,height: 300.0,color: Colors.black45,),
)
外边距
外边距 (margin): Container 分别到父容器Container四边距离.
Container(
width: 200.0,
height: 200.0,
color: Colors.blue,
alignment: Alignment.topLeft,
child: Container(
width: 200.0,
height: 200.0,
color: Colors.black45,
margin: EdgeInsets.all(20.0),
),
)
con