如何在GridView中进行分页(Flutter) [英] how to do pagination in GridView (Flutter)
本文介绍了如何在GridView中进行分页(Flutter)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在GridView中实现分页,我使用 GridView.builder ,我想在用户到达最后一行时以10个项目下载10个项目
I want to implement pagination in GridView I use GridView.builder I want to download 10 by 10 items when the user reaches the last row
推荐答案
您可以使用 NotificationListener
进行此操作。作为一个简单的演示,只要到达页面末尾,它就会增加 GridView
的长度:
You can do this using a NotificationListener
. As a simple demonstration it will increase the length of your GridView
whenever it reaches end of page :
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
}
),
);
这篇关于如何在GridView中进行分页(Flutter)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文