flutter - 如何在 GridView (Flutter) 中进行分页
问题描述
我想在 GridView 中实现分页 我使用GridView.builder我想在用户到达最后一行时下载 10 x 10 个项目
解决方案
您可以使用NotificationListener
. GridView
作为一个简单的演示,它会在到达页面末尾时增加您的长度:
var items_number = 10 ;
return NotificationListener<ScrollNotification>(
onNotification: (scrollNotification){
if(scrollNotification.metrics.pixels == scrollNotification.metrics.maxScrollExtent){
setState(() {
items_number += 10 ;
});
}
},
child: GridView.builder(
itemCount: items_number,
itemBuilder: (context, index) {
//.... the reminder of your code
}
),
);
推荐阅读
- c - 程序创建一个文件,但不会写入它
- c - 简单的链表程序不起作用
- javascript - 当文件托管在 http 服务器上时,IE 11 表单发布到新窗口不起作用
- python-3.x - 向表中添加可变数量的列
- javascript - 如何根据单选类型输入设置标签文本?
- java - 阻塞队列上实现的消费者何时停止监听消息
- javascript - Three.js:将纹理数组传递给shaderMaterial
- apache-kafka - Kafka Streams 持久存储错误:状态存储,可能已迁移到另一个实例
- python - python 无法识别 cx_Oracle
- android - 如何在不同的活动中保存和获取 SharedPreferences?