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

How to update the Firestore query manually after a button press? #33

Closed Maadhav closed 3 years ago

Maadhav commented 3 years ago

I have used this package for displaying the contents of my firestore collection. But I also have implemented filters such as the where clause is changed on the basis of the filter the user has chosen. I tried the store my query in a variable and change it but even after changing the query variable, I am not able to bring the filtered data. Is there any way that I can rebuild the whole PaginatedFirestore widget or any other approach that would help? Thanks.

lucasbstn commented 3 years ago

I had the same issues, adding a key to the paginate firestore widget solved it.

 PaginateFirestore(
        key: UniqueKey(),
        itemBuilder: (context, documentSnapshot) => ListTile(
          leading: CircleAvatar(child: Icon(Icons.person)),
          title: Text(documentSnapshot.data['name']),
          subtitle: Text(documentSnapshot.documentID),
        ),
        query: Firestore.instance.collection('users').orderBy('name'),
      )`
Maadhav commented 3 years ago

@lucasbstn Thanks, this worked for me. Btw way I also had figured out a workaround but this seems the right way to solve the problem.