ListView是Flutter里最常用的Widget了,当屏幕放不下的时候,它可以自带滚动功能。
用法也很简单,又回来仔细看了一下ListView的API和设计。

ListView不仅可以显示一组数据,也可以显示不同类型的列表。

另外,也可以当成一个可以滚动的Column来使用。大部分主界面、详细界面都可以用到它。

使用方法可以参照官方文档:

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

这里有一个列表的小例子:

https://github.com/nisrulz/flutter-examples/tree/master/using_listview

参照示例我修改之前的代码,将卡片通过ListView来展示:

Flutter学习笔记9 (ListView Widget)

在不同的平台和设备上测试兼容性,效果非常不错:

Flutter学习笔记9 (ListView Widget)

下一篇笔记会再仔细看一下如何从网络获取数据并显示。

 

相关文章:

  • 2021-11-08
  • 2021-11-25
  • 2021-06-13
  • 2021-09-22
  • 2021-06-13
  • 2021-10-15
猜你喜欢
  • 2021-08-09
  • 2021-07-07
  • 2021-12-07
  • 2021-10-02
  • 2021-07-12
  • 2021-08-14
相关资源
相似解决方案