阅读背景:

Flutter基础组件-Container

来源:互联网 
一、Container 简单介绍:Container是一种常用的控件,由负责布局、绘画、定位和大小调整的几个控件组成,具体来说,Container是由LimitedBox、ConstrainedBox、 Align、Padding、DecoratedBox和Transform控件组成,而不是将Container子类化来产生自定义效果,您可以用这种新颖的方式组合这些以及其他简单的控件。 注意:使用Container时,通常要有一个父控件,一般情况下不单独使用Container。常用的父控件有Center widget、Padding Widget、Column Widget、Row Widget、Scaffold Widget。   1、构造方法讲解 Container({ Key key, this.alignment,//控制child的对齐方式 this.padding, //设置内边距 Color color, //设置背景颜色 Decoration decoration,//绘制在child下层的装饰,不能与color同时使用 this.foregroundDecoration,//绘制在child上层的装饰 double width, //宽 double height, //高 BoxConstraints constraints,添加到child上额外的约束条件 this.margin,//外边距 this.transform,//设置container的变换矩阵,类型为Matrix4 this.child, //子组件 }) : assert(margin == null || margin.isNonNegative), assert(padding == null || padding.isNonNegative), assert(decoration == null || decoration.debugAssertIsValid()), assert(constraints == null || constraints.debugAssertIsValid()), assert(color == null || decoration == null, 'Cannot provide both a color and a decoration\n' 'The color argument is just a shorthand for "decoration: new BoxDecoration(color: color)".') 一、Container 简单介绍:Container是一种常用的控件,由负责布局、绘画、定位和大小



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: