先在pubspec.yaml引入flutter_staggered_grid_view

dependencies:flutter_staggered_grid_view: ^0.6.2

引入后运行pub get

完整源码:

import 'dart:collection';
import 'dart:math';import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';class PhotoList extends StatelessWidget {const PhotoList({Key? key}) : super(key: key);@overrideWidget build(BuildContext context) {return MaterialApp(home: Scaffold(appBar: AppBar(title: const Text('Flutter Demo'),),body: HomeContent(),),theme: ThemeData(primarySwatch: Colors.blue,),);}
}class HomeContent extends StatefulWidget {const HomeContent({Key? key}) : super(key: key);@override_HomeContentState createState() => _HomeContentState();
}class _HomeContentState extends State<HomeContent> {List _waterFallList = [];@overridevoid initState() {// TODO: implement initStatesuper.initState();var randomNum = new Random();for (var i = 0; i < 40; i++) {Map<String, dynamic> temp = HashMap();temp["height"] = Random().nextInt(150) + 50.5;temp["text"] = "今天的天气真好";_waterFallList.add(temp);}print(_waterFallList);}@overrideWidget build(BuildContext context) {return SingleChildScrollView(child: Container(padding: EdgeInsets.all(10),child: MasonryGridView.count(// 展示几列crossAxisCount: 2,// 元素总个数itemCount: _waterFallList.length,// 单个子元素itemBuilder: (BuildContext context, int index) =>waterCard(_waterFallList[index]),// 纵向元素间距mainAxisSpacing: 10,// 横向元素间距crossAxisSpacing: 10,//本身不滚动,让外面的singlescrollview来滚动physics: const NeverScrollableScrollPhysics(),shrinkWrap: true, //收缩,让元素宽度自适应),),);}Widget waterCard(Map<String, dynamic> item) {return Container(// height: item,// decoration: BoxDecoration(//     border: Border.all(color: Colors.yellow, width: 1),//     borderRadius: BorderRadius.circular(10)),child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: <Widget>[// child: Text(item.toStringAsFixed(0)),Column(children: <Widget>[Image.network("https://www.itying.com/images/flutter/3.png",// height: _items[index]['height'],fit: BoxFit.cover,height: item["height"],width: MediaQuery.of(context).size.width, // 屏幕宽度),// SizedBox(height: 12),],),Text(item["text"],textAlign: TextAlign.center,style: TextStyle(fontSize: 14, color: Color.fromARGB(88, 87, 86, 1))),Row(mainAxisAlignment: MainAxisAlignment.spaceBetween,crossAxisAlignment: CrossAxisAlignment.center,children: [Row(children: [Container(width: 20,height: 20,decoration: BoxDecoration(shape: BoxShape.rectangle,borderRadius: BorderRadius.circular(20),image: DecorationImage(image: NetworkImage('https://pic2.zhimg.com/v2-639b49f2f6578eabddc458b84eb3c6a1.jpg')))),Text("张廷玉",style: TextStyle(fontSize: 15,color: Color.fromARGB(112, 128, 144, 1))),],),Row(mainAxisAlignment: MainAxisAlignment.end,crossAxisAlignment: CrossAxisAlignment.end,children: [Icon(Icons.remove_red_eye_outlined, color: Color.fromRGBO(88, 87, 86, 1)),Text("582",style: TextStyle(fontSize: 15,color: Color.fromARGB(112, 128, 144, 1))),],)],),]));}
}

flutter瀑布式图文列表相关推荐

  1. Flutter页面布局:Flutter AspectRatio、Card卡片组件、卡片图文列表

    1.Flutter AspectRatio组件 AspectRatio 的作用是根据设置调整子元素 child 的宽高比. AspectRatio 首先会在布局限制条件允许的范围内尽可能的扩展,wid ...

  2. 图文列表+富文本解析+折线图示例小程序模板

    简介: 一款多功能示例模板,带图文列表.富文本.折线图.会员中心模块,分享给大家学习. 网盘下载地址: http://kekewl.cc/NiqnJXnde6s0 图片:

  3. 扁平图文列表小程序模板

    介绍: 国外的一款扁平图文列表小程序模板,扁平化风格,样式还不错,分享给大家. 网盘下载地址: http://kekewangLuo.net/K2Z6CzMB3WB0 图片:

  4. 小熊的日记图文列表布局小程序模板

    简介: 小熊的日记图文列表布局小程序模板 网盘下载地址: http://kekewangLuo.net/aTJQAb3h6ej0 图片:

  5. 图文列表+欢迎页面+音乐控制小程序模板

    介绍: 图文列表+欢迎页面+音乐控制小程序模板,带微信小程序项目导入使用说明. 安装方式介绍: 1:安装后图标: 登录,随意一个微信号,扫描后即可登录 2:选择无appid:项目名称随意,地址选择下载 ...

  6. Vue学习笔记-项目开发2.5图文列表展示(周末去哪玩儿)

    这个图文列表是上图下文字的形式,只是样式上的不同 <template><div><div class="title">周末去哪儿</div ...

  7. C语言界面列表的滑动效果,jQuery+ajax实现滚动到页面底部自动加载图文列表效果(类似图片懒加载)...

    本文实例讲述了jQuery+ajax实现滚动到页面底部自动加载图文列表效果.分享给大家供大家参考,具体如下: /p> "http://www.w3.org/TR/xhtml1/DTD/ ...

  8. MUI-list(列表),普通列表、带箭头列表、带数字角标列表、带图文列表

    本文主要介绍list(列表)的几种展现形式:普通列表.带箭头列表.带数字角标列表.带图文列表 效果图如下: 1.普通列表:只需要在ul节点上添加.mui-table-view类.在li节点上添加.mu ...

  9. 2023最新小熊的日记图文列表布局小程序模板源码

    正文: 小熊的日记图文列表布局小程序模板源码,有兴趣的自行去测试,其它的就没什么好介绍的了,注意是模板源码,没有后台,觉得不错的自行拿去修改. 程序: wwetho.lanzoui.com/is7lQ ...

最新文章

  1. sql查询字段结果显示部分_SQL语句结构分析
  2. 转: GridView:当鼠标滑过,行的背景颜色发生变化
  3. 手把手教你在Tensorflow实现BEGAN 达到惊人的人脸图像生成效果
  4. wan886网址导航 Bo9bo高清电影 两个图标 怎么都删不掉
  5. HDU-5706(DFS)
  6. 职务与职级并行套改表_公务员职务职级并行时,15年的主仼科员能套四级调研员吗?...
  7. 计算机视觉与深度学习 | 基于MATLAB 深度学习工具实现简单的数字分类问题(卷积神经网络)
  8. qt android程序联网死机,qt android开发出现致命错误
  9. ubuntu指向python3_ubuntu安装python3.7,并更新python默认指向为python3.7
  10. 基于发起源判断CSRF***的方法
  11. Nginx作为web服务器的安装配置
  12. asp.net程序中最常用的三十三种编程代码(转自CSDN)
  13. mysql_use_result与mysql_store_result异同点
  14. Oracle高级查询之GROUP BY
  15. 去哪里找自媒体视频剪辑中的素材?
  16. python正则匹配中文
  17. 计算机flops测试,谁知道哪个软件可以测试CPU是多少GFLOPS?
  18. Mysql SQLserver Oracle 数据库中获取系统时间,年,月,日单个获取
  19. [技术分享 – FCS 篇] 驭龙五式3之飞龙在天:安装 FCS 服务器
  20. Java 高并发之魂

热门文章

  1. 微前端实践--webpack5模块联邦
  2. 【数据结构】【c】关于malloc和realloc
  3. 从线性分类器到卷积神经网络
  4. python中常见的漏洞_Python常见安全漏洞及修复方法集合!你所不会的这里都有!...
  5. Android学习笔记 56. TabLayout 选项卡布局
  6. win10 以 十六进制 形式(方式) 查看文件 内容
  7. Linux教程从入门到精通
  8. ubuntu18.04完全卸载nvidia显卡驱动
  9. postgresql灾备切换
  10. java web中图形验证码的生成(英文和数字混合的验证码)