Flutter: How to utilize lazy loading in SliverList?

156 views Asked by At
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();
              }
        },
),

I have this ListView that I have implemented and works normally with Controller and itemCount. How can I implement this in a sliver list, as one of a slivers children?

0

There are 0 answers