Is there a way to get StreamBuilder to load content slightly before the user scrolls down to it to reduce delay (Flutter)?

Viewed 106

Currently my app loads the information (including pictures) into cards from Cloud Firestore, but it only starts loading the information when it appears on the user's screen. I used FadeInImage in _makeCard to make it a bit more usable while loading, but it's still too slow. Is there a way to make StreamBuilder load, for example, the nearest 10 cards that are off the screen? If not, is there a better way to create a list that is loaded from Firestore? This is my code currently:

StreamBuilder(
  stream: Firestore.instance.collection('Cards').snapshots(),
  builder: (context, snapshot) {
    return SliverList(
      delegate: SliverChildBuilderDelegate(
        (context, index) {
          return _makeCard(context, snapshot.data.documents[index]);
        },
        childCount:
          snapshot.hasData ? snapshot.data.documents.length : 0,
     ),
  );
})

I don't have a lot of experience with coding, so let me know if there is anything I can clarify.

0 Answers
Related