颤振中的分页无法正确加载数据

时间:2019-08-29 00:17:24

标签: flutter dart

我在我的应用程序中使用flutter页面插件进行分页:

Future<List<KCSamplesModel>> pageData(
  BuildContext context, int previousCount) async {
print("called!!!!!");
List<KCSamplesModel> dummyList = List();

if (formsPageNumber < totalFormsPages && _firstOpen == false) {
  print(formsPageNumber < totalFormsPages);
  print(_firstOpen);
  await Future.delayed(Duration(seconds: 0, milliseconds: 1000));
  await getForms(context, false, "").then((onValue) {
    dummyList = allForms;
  });
} else {
  print(_firstOpen);
  _firstOpen = false;
  dummyList = allForms;
}
debugPrint("news_dummyList" + dummyList.length.toString());

return dummyList;
}

Pagination<KCSamplesModel>(
                pageBuilder: (currentSize) =>
                    pageData(context, currentSize),
                itemBuilder: (index, item) {
                  .....
                })

我的问题是,当我第一次进入页面时..第0页已成功加载并且得到了打印

flutter: called!!!!!
flutter: true
flutter: news_dummyList10

我滚动到结尾,我成功加载了第1页,并且得到了

flutter: called!!!!!
flutter: true
flutter: false
flutter: news_dummyList20

然后我滚动加载更多内容,则不会发生任何事情,甚至不会调用pageData!我返回并返回该页面,滚动页面2将成功加载,然后再次滚动将不执行任何操作。我返回并滚动它将再加载一页,依此类推!

如何解决这个问题以及为什么会发生?

0 个答案:

没有答案