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

Limit items per page and know when is fetching more documents #3

Closed d-apps closed 4 years ago

d-apps commented 4 years ago

Can we control the limit of items per page? if so, how?

How to know when is fetching more documents, like a bool variable, to show some CircularProgressIndicator with "loading more data" to the user?

vedartm commented 4 years ago

There is an attribute itemsPerPage to set number of items in one page. You can use it like this

      PaginateFirestore(
        itemBuilder: (context, documentSnapshot) => ListTile(
          leading: CircleAvatar(child: Icon(Icons.person)),
          title: Text(documentSnapshot.data['name']),
          subtitle: Text(documentSnapshot.documentID),
        ),
        // orderBy is compulsary to enable pagination
        query: Firestore.instance.collection('users').orderBy('name'),
        itemsPerPage: 10
      ),
vedartm commented 4 years ago

I am closing the issue now. If you face any related issue, feel free to reopen it. Thanks for using the package, hope it solved your use case.

waletoyo1 commented 3 years ago

When "itemsPerPage" attribute is used, can the firestore "limit" method be used together? Thanks.

vedartm commented 3 years ago

itemsPerPage internally uses firestore's limit method anyways @waletoyo1

waletoyo1 commented 3 years ago

Thanks