列表有以下分类:
1、垂直列表
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return Center(
child: ListView (children: const [
Icon(Icons.search, color: Colors.red, size: 50),
SizedBox(height: 100),
Icon(ItyingIcon.weix, size: 50, color: Color.fromARGB(255, 9, 240, 151)),
SizedBox(height: 100),
Icon(ItyingIcon.gouwu, size: 50, color: Colors.black),
SizedBox(height: 100),
Icon(ItyingIcon.weix, size: 50, color: Color.fromARGB(255, 27, 71, 54)),
],)
);
}
}
2、垂直图文列表
class MyApp1 extends StatelessWidget {
const MyApp1({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ListView(
padding: const EdgeInsets.fromLTRB(0, 10, 0, 0),
children: <Widget>[
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
],
);
}
}
3、水平列表
scrollDirection: Axis.horizontal
class MyApp2 extends StatelessWidget {
const MyApp2({super.key});
@override
Widget build(BuildContext context) {
return SizedBox( //指定固定尺寸
// width: 100.0,
height: 100.0,
child: ListView(
scrollDirection: Axis.horizontal, //水平
padding: const EdgeInsets.fromLTRB(0, 10, 0, 0),
children: <Widget>[
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
Image.network(
"https://dashanbook.oss-cn-shenzhen.aliyuncs.com/46aa6e030985487894f34196c4df3ee4.jpg"),
],
)
);
}
}
4、动态列表
(1)for循环实现动态列表
class MyApp3 extends StatelessWidget {
MyApp3({Key? key}) : super(key: key) {
print(ListText);
}
List<Widget> _initListData() {
List<Widget> list = [];
for (var i = 0; i < ListText.length; i++) {
list.add(ListTile(
leading: Image.network("${ListText[i]["imageUrl"]}"),
title: Text("${ListText[i]["title"]}"),
subtitle: Text("${ListText[i]["author"]}"),
));
}
return list;
}
@override
Widget build(BuildContext context) {
return ListView(children: _initListData());
}
}
(2)map实现动态列表
class MyApp4 extends StatelessWidget {
MyApp4({Key? key}) : super(key: key) {
print(ListText);
}
List<Widget> _initListData() {
var list = ListText.map((value) {
return ListTile(
leading: Image.network("${value["imageUrl"]}"),
title: Text("${value["title"]}"),
subtitle: Text("${value["author"]}"),
);
});
return list.toList();
}
@override
Widget build(BuildContext context) {
return ListView(children: _initListData());
}
}
(3)ListView.builder实现动态列表
class MyApp5 extends StatelessWidget {
List<String> list = [];
MyApp5({Key? key}) : super(key: key) {
for (var i = 0; i < 30; i++) {
list.add("数据$i");
}
}
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: list.length, //循环的次数
itemBuilder: (context, index) {
return ListTile(
title: Text("${list[index]}"),
);
},
);
}
}
 

6、Flutter 列表组件 滑动的更多相关文章

  1. ListView 基础列表组件、水平 列表组件、图标组件

    一.Flutter 列表组件概述 列表布局是我们项目开发中最常用的一种布局方式.Flutter 中我们可以通过 ListView 来定义 列表项,支持垂直和水平方向展示.通过一个属性就可以控制列表的显 ...

  2. Flutter中的可滚动列表组件-PageView

    PageVIew,可滚动的视图列表组件,而且每一个子组件的大小都和视图窗口大小一样. 属性: controller -> PageController 用于控制视图页面滚动到的位置 childr ...

  3. Flutter学习笔记(12)--列表组件

    如需转载,请注明出处:Flutter学习笔记(12)--列表组件 在日常的产品项目需求中,经常会有列表展示类的需求,在Android中常用的做法是收集数据源,然后创建列表适配器Adapter,将数据源 ...

  4. Flutter 实战(一):列表项内容可自定义的列表组件

    前言 本篇文的目的是熟练掌握 Flutter 组件的封装,并且使用回调函数实现主要功能. 本组件的设计灵感来源于 Element 组件库的 table 组件. 正题 定义回调函数 在此之前,必须要了解 ...

  5. React-Native新列表组件FlatList和SectionList学习 | | 联动列表实现

    React-Native在0.43推出了两款新的列表组件:FlatList(高性能的简单列表组件)和SectionList(高性能的分组列表组件). 从官方上它们都支持常用的以下功能: 完全跨平台. ...

  6. Flutter常用组件(Widget)解析-ListView

    一个可滚动的列表组件 不管在哪,列表组件都尤为重要和常用. 首先来看个例子: import 'package:flutter/material.dart'; void main () => ru ...

  7. 07Flutter ListView基础列表组件、水平列表组件、图标组件

    ListView:     ListView:参数     scrollDirection:Axis.horizontal:水平列表.Axis.vertical垂直列表     padding:内边距 ...

  8. Flutter ListTile - Flutter每周一组件

    该文章属于[Flutter每周一组件]系列,其它组件可以查看该系列下的文章,该系列会不间断更新:所有组件的demo已经上传值Github: https://github.com/xj124456/fl ...

  9. 列表组件抽象(2)-listViewBase说明

    这是我写的关于列表组件的第2篇博客.前面的相关文章有: 1. 列表组件抽象(1)-概述 listViewBase是列表组件所有文件中最核心的一个,它抽象了所有列表的公共逻辑,将来如果有必要添加其它公共 ...

  10. 可展开的列表组件——ExpandableListView深入解析

    可展开的列表组件--ExpandableListView深入解析 一.知识点 1.ExpandableListView常用XML属性 2.ExpandableListView继承BaseExpanda ...

随机推荐

  1. Java11配置maven

    这里假设Java11和maven都正确安装,使用的版本为Java11.maven3.6.1 测试环境变量 Java win + r 打开运行,输入 cmd,打开命令行提示符,输入java --vers ...

  2. Windows虚拟机环境下Linux设置固定IP地址

    Linux 设置固定IP地址 安装环境是VMware Workstation Pro 15 安装完linux之后需要做的第一件事就是配置网络,有了网络我们可以下载插件,使用xshell工具连接等等 i ...

  3. [Python急救站课程]温度转换程序

    华氏温度转换为摄氏度的温度转换程序共有三种写法 一.简单的温度转换程序 TempStr = input("请输入带有符号的温度值: ") # TemStr表示命令,表示占位符.=为 ...

  4. 关于RS485通讯TVS器件选择的经验

    先说经验结论 如果你的RS485用于频繁热拔插, 比如作为手持终端使用, 且手持器与目标板非隔离, 那么使用6.8CA可能是更好的选择. 因为有热拔插会产生浪涌, 而且在非隔离的场合有些工业设备接地也 ...

  5. Istio:微服务开发的终极利器,你还在为繁琐的通信和部署流程烦恼吗?

    引言 在前面的讲解中,我们已经提及了微服务的一些弊端,并介绍了Istio这样的解决方案.那么,对于我们开发人员来说,Istio究竟会带来哪些变革呢?今天我们就来简要探讨一下! Kubernetes简单 ...

  6. 神经网络入门篇:激活函数(Activation functions)

    激活函数 使用一个神经网络时,需要决定使用哪种激活函数用隐藏层上,哪种用在输出节点上.到目前为止,之前的博客只用过sigmoid激活函数,但是,有时其他的激活函数效果会更好. 在神经网路的前向传播中, ...

  7. (Good topic)哈希表:最长回文串(3.19 leetcode每日打卡)

    给定一个包含大写字母和小写字母的字符串,找到通过这些字母构造成的最长的回文串. 在构造过程中,请注意区分大小写.比如 "Aa" 不能当做一个回文字符串. 注意: 假设字符串的长度不 ...

  8. Ubuntu 20.04 挂载局域网络共享硬盘

    创建挂载目录 mkdir /media/nas 创建认证文件.若无密码可以忽略这一步. sudo vim /root/.examplecredentials 按照以下格式写入用户名密码: userna ...

  9. Android 的异步消息处理机制

    前言 Android中的异步消息处理机制主要有四部分:Message.Handler.MessageQuene.Looper.这一消息处理机制也称为Handler机制.Handler机制是支撑整个An ...

  10. 【结对作业】第一周 | 学习体会day06

    初步做了app的页面 change作为mysql的关键字,不可以作为命名,否则报错 做了两条线路的中转 初步学习了frame标签,打算明天实现页面的部分切换