前言
flutter中的Container组件,相当于前端开发的Div组件或者ios开发中的view控件。
源码
Container({
Key key,
this.alignment, // 对齐方式
this.padding, // 内边距
Color color,
Decoration decoration, // 背景描述
this.foregroundDecoration, // 前景描述
double width, // 宽
double height, // 高
BoxConstraints constraints,// 最大最小约束
this.margin, // 外边距
this.transform,//
this.child, //
this.clipBehavior = Clip.none,
}) : assert(margin == null || margin
测试代码
child: Container(
child:Container(
color: Colors.lightBlue,
width: 150,
height: 30,
child:Text("今天学习Container组件", textAlign: TextAlign.right),
),
alignment: Alignment.centerLeft,
// color: Colors.blueAccent,
width: 500,
height: 200,
padding:EdgeInsets.only(left: 50),
decoration:BoxDecoration(
color: Colors.lightBlue,
border:Border.all(width: 5.0,color: Colors.red),
gradient:LinearGradient(
colors: [
Colors.yellow,
Colors.red,
Colors.green
]
)
),
foregroundDecoration: BoxDecoration(
border:Border.all(width: 2.0,color: Colors.blue),
),
),
运行效果
屏幕快照 2020-01-06 下午5.14.33.png