我想在GridView中实现分页我使用GridView.builder我想在用户到达最后一行时下载10×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
                    }
                ),
    );

Dart相关问答推荐

寻找provider context 的flutter问题

ListView 不会刷新,而附加列表会刷新 (Flutter)

当 ng-repeat 嵌套在 AngularDart 中时访问外部 $index

我可以动态应用 Dart 的字符串插值吗?

你如何在 Polymer 中调度和监听自定义事件?

try 部署到 Google AppEngine 时出现 Dev_appserver.py 错误

Flutter更新导航栏

什么是NoSuchMethod错误,如何修复?

有没有办法知道我的Flatter应用程序使用的是哪个Android API版本?

摆动中的可滚动导轨

属性 'docs' 不能无条件访问,因为接收到的可能是 'null' Flutter

如何在flatter中使用SQFlite更新数据库表

Flatter BLoC-如何将参数传递给事件?

在 Dart 中调用异步函数而不等待,例如启动一个线程

Dart 中的snapshot快照概念是什么?

Dart 后期初始化final变量

我应该如何在 Dart 中测试 Future?

在 Dart 中打开类类型

在 Dart 中,bool是否有parse,就像int一样?

dart 折叠(Fold)与减少(Reduce)