vedartm / paginate_firestore

A flutter package to simplify pagination with firestore data 🗃
https://pub.dev/packages/paginate_firestore
MIT License
113 stars 136 forks source link

Access next DocumentSnapshot #96

Closed kiloki-official closed 2 years ago

kiloki-official commented 3 years ago

Hi, is it possible to access next DocumentSnapshot from the builder ?

I can do it using a streamsubscription, but I'd rather access it through your package.

Thanks

vedartm commented 2 years ago

Hi @kiloki-official. Now with v1.0.3, you can access the previous or next document snapshot from the itemBuilder like this

        itemBuilder: (context, documentSnapshots, index) {
          final data = documentSnapshots[index].data() as Map?;
          final previous = documentSnapshots[index - 1].data() as Map?;
          // If index is not the last index of the documentSnapshots
          final next = documentSnapshots[index + 1].data() as Map?;
          return ListTile(
            leading: const CircleAvatar(child: Icon(Icons.person)),
            title: Text(data['name']),
            subtitle: Text(documentSnapshots[index].id),
          );
        },