我爱模板网 > 建站教程 > APP开发,混合APP >  Flutter笔记36:ListBody列表组件正文

Flutter笔记36:ListBody列表组件

ListBody常常配合Row实现宽度不同的水平排列,或者配合Column实现高度不通的垂直排列,还可以根据自身的reverse属性实现列表内容的正序或倒叙排列。也可以和ListView配合使用:
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        ListBody(
          //对齐方式,注意,父元素是Column,这里只能是vertical垂直排列,如果像用Axis.horizontal水平排列,父元素必须是Row
          mainAxis: Axis.vertical,
          //内容是否反向
          reverse: true,
          children: [
            Container(
              color: Colors.red,
              width: 50.0,
              height: 50.0,
              child: Text(
                'A',
                style: TextStyle(
                  color: Colors.white,
                ),
              ),
            ),
            Container(
              color: Colors.orange,
              width: 100.0,
              height: 100.0,
              child: Text(
                'B',
                style: TextStyle(
                  color: Colors.white,
                ),
              ),
            ),
            Container(
              color: Colors.blue,
              width: 150.0,
              height: 150.0,
              child: Text(
                'C',
                style: TextStyle(
                  color: Colors.white,
                ),
              ),
            ),
          ],
        )
      ],
    );
  }



部分素材资源来源网站,本站提供免费下载,如有侵权请联系站长马上删除!
上一篇:Flutter笔记35:Container组件 下一篇:Flutter实现上拉加载下拉刷新
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
选择头像:
最新评论

猜你喜欢