列表有以下分类:
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. [CISCN 2019华东南]Web11

    看到下面connection 里面的内容有一点像抓包出来的 就抓包试试 似乎感觉也没有什么用 看到这个东西,那么就想到改IP 添加X-Forwarded-For:127.0.0.1 发现这个IP随着我 ...

  2. .Net核心级的性能优化(GC篇)

    1.前言 大部分人对于.Net性能优化,都停留在业务层面.或者简单的.Net框架配置层面.本篇来看下.Net核心部分GC垃圾回收配置:保留VM,大对象,独立GC,节省内存等.Net8里面有很多的各种G ...

  3. js数据结构--集合

    <!DOCTYPE html> <html> <head> <title></title> </head> <body&g ...

  4. Chromium Trace and Perfetto使用详解

    1. Trace chromium 在 base 库中提供了 base::trace_event::TraceLog 类,该类是 TRACE_EVENT* , TRACE_COUNTER* 等宏的底层 ...

  5. 2022/07/16暑期集训考试 day1

    T1 取餐号 看到数据范围 直接锁定埃氏筛和线性筛 我打的是一个优化一点的埃氏筛 #include<bits/stdc++.h> using namespace std; #define ...

  6. Codeforces Round #697 (Div. 3) A~E题解

    写在前边 状态及其不佳,很累很困,还好\(unrated\)了 链接:Codeforces Round #697 (Div. 3) A. Odd Divisor 链接:A题链接 题目大意: 判断一个数 ...

  7. UIPath之Excel操作

    你的选择是做或不做,但不做就永远不会有机会. 一. UIPath操作Excel的两组方法 1. App Integration > Excel   特点: 对Excel里的操作必须包含在Exec ...

  8. MIGO配置过账后自动打印

    1.业务需求 本文档介绍,当MIGO发货过账时,自动打印自开发表格. 2.打印程序 复制标准配置中调用的程序和子例程,到新的程序(路径可参考下文系统配置) 只用复制子例程entry_wa01即可,参考 ...

  9. PageHelper插件注意事项

    PageHelper插件注意事项 使用PageHelper.startPage后要紧跟查询语句 下面的代码就有可能出问题: PageHelper.startPage(10, 10); if(param ...

  10. AutoCAD ObjectARX 二次开发(2020版)--1,下载和部署开发环境--

    教程说明: 本教程为2019年10月开始编撰,使用CAD官方最新版本的软件和库.对旧版本仍有参考价值. 本教程中使用的各种软件版本为官方指定匹配版本. 本教程需要你拥有编程基础,对于普通编程常识不再敷 ...