美文网首页
Flutter--Expanded学习

Flutter--Expanded学习

作者: 小迷糊_dcee | 来源:发表于2020-12-01 23:17 被阅读0次

    一、介绍

    自适应填充布局,类型android的LinearLayout的weight权重

    二、expanded源码

     const Expanded({
        Key key,
        int flex = 1,//弹性
        @required Widget child,//子组件
      }) : super(key: key, flex: flex, fit: FlexFit.tight, child: child);
    

    三、属性介绍

    属性 说明
    flex 弹性

    四、demo

    return Container(
          color: Colors.black26,
          width: 600,
          height: 100,
          child: Row(
            children: [
              Expanded(
                  flex: 1,
                  child: Container(
                    color: Colors.blue,
                  )),
              Expanded(
                flex: 2,
                  child: Container(
                      color: Colors.red,
              )),
    
              Expanded(
                  flex: 1,
                  child: Container(
                    color: Colors.yellow,
                  )),
            ],
          ),
        );
    

    1:2:1的宽度


    企业微信截图_16068358028073.png

    相关文章

      网友评论

          本文标题:Flutter--Expanded学习

          本文链接:https://www.haomeiwen.com/subject/csiewktx.html