代码之家  ›  专栏  ›  技术社区  ›  splurring

Flutter:如何在SliverList中利用懒惰加载?

  •  0
  • splurring  · 技术社区  · 1 年前
    ListView.builder(
        controller: _scrollController,
        itemCount: _allDocs.length + 1, // Add 1 for loading indicator
        itemBuilder: (context, index) {
             print("All docs here");
             print(index);
             if (_allDocs.length % 10 != 0) hasMore = false;
                if (index < _allDocs.length) {
                  final post = _allDocs[index];
                     final postModel = PostModel.fromDocument(post);
                     return PostWidget(post: postModel);
                  } else {
                     return hasMore
                        ? const Center(child: CircularProgressIndicator())
                        : const NoMorePostWidget();
                  }
            },
    ),
    

    我有这个ListView,我已经实现并正常使用它 控制器 itemCount 。作为一个slivers孩子,我如何在slivers列表中实现这一点?

    0 回复  |  直到 1 年前
    推荐文章