学习了Flutter,来分享一下学习的一些常用的知识,先来说说ListView

案例效果:

ListView是一个类似列的widget,它的内容对于其渲染框太长时会自动提供滚动。

ListView 摘要:
用于组织盒子中列表的特殊Column
可以水平或垂直放置
检测它的内容超过显示框时提供滚动
比Column配置少,但更易于使用并支持滚动

构建ListView有四个选项:

默认构造函数采用子类的显式List <Widget>。此构造函数适用于具有少量子项的列表视图,因为构造List需要为可能在列表视图中显示的每个子项执行工作,而不仅仅是那些实际可见的子项。

该ListView.builder构造函数采用IndexedWidgetBuilder,它建立在孩子的需求。此构造函数适用于具有大量(或无限)子项数的列表视图,因为仅为那些实际可见的子项调用构建器。

该ListView.separated构造函数有两个IndexedWidgetBuilder S: itemBuilder按需建立个子项目,separatorBuilder 同样建立其出现在子项之间的分隔符的孩子。此构造函数适用于具有固定数量子项的列表视图。

该ListView.custom构造需要SliverChildDelegate,它提供了自定义子模型的其他方面的能力。例如,SliverChildDelegate可以控制用于估计实际上不可见的子项大小的算法。

官方文档介绍:

https://docs.flutter.io/flutter/widgets/ListView-class.html

案例代码:

class UITest3_ListView extends StatelessWidget{

  List<Widget> list = <Widget>[
new ListTile(
title: new Text('Mi is One',
style: new TextStyle(fontWeight: FontWeight.w500,fontSize: 20),
),
subtitle: new Text("85 W zq"),
leading: new Icon(Icons.theaters,color: Colors.blue[500]),
),
new ListTile(
title: new Text("Test at Tow",style: new TextStyle(fontWeight: FontWeight.w500,fontSize: 20)),
subtitle: new Text("666 Car"),
leading: new Icon(Icons.list,color: Colors.blue[500])
),
new ListTile(
title: new Text('Three',
style: new TextStyle(fontWeight: FontWeight.w500,fontSize: 20),
),
subtitle: new Text("85 W zq"),
leading: new Icon(Icons.theaters,color: Colors.blue[500]),
),
new ListTile(
title: new Text("Four",style: new TextStyle(fontWeight: FontWeight.w500,fontSize: 20)),
subtitle: new Text("666 Car"),
leading: new Icon(Icons.list,color: Colors.blue[500]),
onTap: (){
Fluttertoast.showToast(
msg: " Four",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIos: 1,
backgroundColor: Colors.blue,
textColor: Colors.white
);
}, )
]; @override
Widget build(BuildContext context) {
// TODO: implement build
return new Scaffold(
appBar: new AppBar(
title: Text("ListView"),
),
body: new Center(
child: new ListView(
children: list,
),
),
);
}
}

flutter -------- ListView的使用的更多相关文章

  1. Flutter ListView 列表组件

    列表常见的情况: 1.垂直列表 2.垂直图文列表 3.横向列表 4.动态列表 名称 类型 说明 scrollDirection Axis Axis.horizontal 横向列表 Axis.verti ...

  2. Flutter——ListView组件(平铺列表组件)

    ListView的常见参数: 名称 类型 说明 scrollDirection Axis Axis.horizontal 水平列表 Axis.vertical 垂直列表 padding EdgeIns ...

  3. flutter ListView列表和导航传值以及回调

    main.dart import 'package:flutter/material.dart'; void main(){ return runApp(MyApp()); } class Produ ...

  4. flutter ListView简介

    child: new Container( child: new Center( child: ListView( shrinkWrap:true, children: <Widget>[ ...

  5. Flutter - ListView禁止用户上下滑动

    ListView禁止用户上下滑动可以使用physics属性 physics: const NeverScrollableScrollPhysics()

  6. flutter ListView 页面滚动组件

    ListView class A scrollable list of widgets arranged linearly. ListView is the most commonly used sc ...

  7. flutter ListView嵌套高度问题

    ListView嵌套时高度无法自适应,需要设置高度才可以显示,设置以下属性可以解决上述问题 shrinkWrap: true, physics: NeverScrollableScrollPhysic ...

  8. Flutter 自定义列表以及本地图片引用

    前言 上篇关于Flutter的文章总结了下标签+导航的项目模式的搭建,具体的有需要的可以去看看Flutter分类的文章,这篇文章我们简单的总结一下关于Flutter本地文件引用以及简单的自定义List ...

  9. flutter - 01 基础介绍以及ListView

    这篇主要讲flutter最基本的操作.我们从一个实例入手,先不需要知道它里面的每一行是什么意思,我会慢慢说. main.dart import 'package:flutter/material.da ...

随机推荐

  1. C#中方法、类等的默认访问修饰符~

    C# 方法默认访问级别 : private C# 类默认访问级别 : internal 1.命名空间下的元素的默认访问修饰符 public : 同一程序集的其他任何代码或引用该程序集的其他程序集都可以 ...

  2. 18.12.09-C语言练习:兔子繁衍问题 / Fibonacci 数列

    题目: 问题解析: 这是典型的/Fibonacci 数列问题.具体这里不赘述. 问题中不论是初始的第1对兔子还是以后出生的小兔子都是从第3个月龄起每个月各生一对兔子. 设n1,n2,n3分别是每个月1 ...

  3. PHP图像处理(GD库)

    一.图像处理概述 1.开启GD2图像扩展库 ①PHP不仅限于只产生HTML的输出,还可以创建与操作多种不同格式的图像文件.PHP提供了一些内置的图像处理函数,也可以使用GD函数库创建新图像或处理已有的 ...

  4. php读取和导出Excel文件

    require 'vendor/PHPExcel/PHPExcel.php';require 'vendor/PHPExcel/PHPExcel/IOFactory.php'; public func ...

  5. IO流(三)

    五.Java序列化 概述 Java序列化是指把Java对象转换为字节序列的过程 Java反序列化是指把字节序列恢复为Java对象的过程 当两个Java进程进行通信时,发送方需要把这个Java对象转换为 ...

  6. shell里连接数据库,将结果输出到变量

    result=$(sqlplus -s 'ccc/ccc@21.96.34.34:1521'<<EOF ..... EOF )

  7. Typescript日期Date如何做格式化字符串

    ·使用一个date-fns/format的库 安装npm i date-fns --save import format from 'date-fns/format'; const newdate = ...

  8. nginx和php-fpm的进程启停重载总结

    nginx和php-fpm对于-USR2.-HUP信号的处理方式不一样: TERM, INT(快速退出,当前的请求不执行完成就退出) QUIT (优雅退出,执行完当前的请求后退出) HUP (重新加载 ...

  9. github收藏夹

    技术面试必备基础知识 https://github.com/CyC2018/CS-Notes 程序员简历模板列表 https://github.com/geekcompany/ResumeSample ...

  10. Linux性能优化-理解平均负载

    1 平均负载含义 当系统变慢的时候,我们一般使用 top 或 uptime 命令来查看系统平均负载情况. 正确定义:单位时间内,系统中处于可运行状态和不可中断状态的平均进程数.错误定义:单位时间内的c ...