flutter 系统组件学习 -Container组件

前言

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
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 欲戴王冠,必承其重。 第一次看见这句话是在高中,是我们学校学霸的座右铭。当时被这句话惊艳到了,不愧是学霸,连座右铭...
    伊人昔岸阅读 1,919评论 2 3
  • 又和我妈又吵架了,又是因为没给家里钱。 我叫阿静今年20岁,来自张家界一个山旮旯里,现在工作刚转正,在深圳一家公司...
    耳東婧阅读 321评论 0 0
  • 2017年8月11日,是我来慧聪报道的日子,和我交流的是开朗可爱的娇姐,问我为什么要来慧聪,我说因为这里的培训,为...
    杨颖__指数成长阅读 523评论 3 4

友情链接更多精彩内容