Container(
child: Text('这是一个Container组件',style: TextStyle(fontSize: 16.0, color: Colors.white),),
// 子内容的对齐方式,并不是Container的对齐方式
// 完全居中: center; 还有:topLeft,topRight依次类推...
alignment: Alignment.topLeft,
// 高度
height: 400,
// 宽度
width: 300,
// 颜色
// color: Colors.green,
// 内边距(四边同时设置)
// padding: const EdgeInsets.all(10.0),
// 内边距(分别设置) 依次为:左上右下
padding: EdgeInsets.fromLTRB(20, 30, 40, 50),
// 外边距 (同理与内边距一样)
margin: EdgeInsets.all(20.0),
// [装饰]渐变(与上面的color不能同时存在)
decoration: BoxDecoration(
// 渐变叠加[线性渐变]
gradient: LinearGradient(
// 颜色集合
colors: [Colors.red,Colors.pink,Colors.purple]
),
// 边框线
border:Border.all(
width: 5.0, // 边框线的宽度
color: Color(0xff8800ff),// 线的颜色
style: BorderStyle.solid, // 实线(默认)
)
),
)
container.png
网友评论