vedartm / paginate_firestore

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

Instead of 15 it is Fetching all the documents from the collection #107

Closed narimetisaigopi closed 2 years ago

narimetisaigopi commented 2 years ago

return PaginateFirestore( //item builder type is compulsory. itemBuilder: (context, documentSnapshots, index) { final data = documentSnapshots[index].data() as Map; print("index $index"); return Expanded( child: ListTile( leading: CircleAvatar(child: Icon(Icons.person)), title: data == null ? Text('Error in data') : Text(""), subtitle: Text(""), ), ); }, // orderBy is compulsory to enable pagination query: FirebaseFirestore.instance.collection('users').orderBy('name'), //Change types accordingly itemBuilderType: PaginateBuilderType.listView, shrinkWrap: false, // to fetch real-time data isLive: true, );

ghost commented 2 years ago

If you're fetching all of the documents, why is there a need to use pagination?

p4-k4 commented 2 years ago

Revert back to standard get() or snapshots() then. Your goal is counter-intuitive to this packages goals lol.

narimetisaigopi commented 2 years ago

If you're fetching all of the documents, why is there a need to use pagination?

instead of 15 records, package fetching all the records

azmilazizi commented 2 years ago

If you're fetching all of the documents, why is there a need to use pagination?

He wanted to use the package for pagination + snapshot feature but the pagination feature isnt working. Is there any fix for this?

waqadArshad commented 2 years ago

@vedartm @austinn @ghprod @atrope @adamdupuis @claudemircasa Hi, I am experiencing the same issue. Can someone help? I put the itemsPerPage as 1 and it is still fetching all the results without scrolling the list.

PaginateFirestore(
                        scrollDirection: Axis.horizontal,
                        shrinkWrap: true,
                        itemsPerPage: 3,
                        isLive: true,
                        itemBuilder: (context, documentSnapshots, index) {
                          MyWorldModel data = MyWorldModel.fromJson(documentSnapshots[index].data());
                          return GestureDetector(
                            onTap: () async {
                              UserModel umdl =
                              await authController.getAUser(data.id);
                              Get.to(() => Home(showAbleUserData: umdl));
                            },
                            child: MyWorldTiles(
                              profileImage: data.profileImage,
                              personName: data.personName,
                              department: data.profession,
                              distance: data.distance,
                            ),
                          );
                        },
                        query: firebaseFirestore
                            .collection('Users')
                            .doc(authController.userModel.value.id)
                            .collection('TheyLikedMe')
                            .orderBy('id'),
                        itemBuilderType: PaginateBuilderType.listView,
                      ),
waqadArshad commented 2 years ago

If you're fetching all of the documents, why is there a need to use pagination?

I think that is when someone needs pagination. now the thing is how to achieve that using this package? because I haven't been able to find clear documentation about that. and if it is to be achieved simply as the Readme of the package defines, it doesn't work like that. It fetches all the documents.

vedartm commented 2 years ago

@waqadArshad Thanks for using the package. I think the problem is you are setting shrinkWrap to true. It expanded the list internally and triggers the end of the page call all at once.

Set it to false and it should work fine.

vedartm commented 2 years ago

Please feel to reopen this if you are still facing this issue.

waqadArshad commented 2 years ago

Please feel to reopen this if you are still facing this issue.

Hi @vedartm, I did try removing it and also setting it to false with the item count of 1 (because right now I don't have a long list) to test this. but still, all the docs got fetched.

PaginateFirestore(
                  scrollDirection: Axis.horizontal,
                  shrinkWrap: false,
                  itemsPerPage: 1,
                  isLive: true,
                  itemBuilder: (context, documentSnapshots, index) {
                    MyWorldModel data =
                        MyWorldModel.fromJson(documentSnapshots[index].data());
                    return GestureDetector(
                      onTap: () async {
                        UserModel umdl = await authController.getAUser(data.id);
                        Get.to(() => Home(showAbleUserData: umdl));
                      },
                      child: MyWorldTiles(
                        profileImage: data.profileImage,
                        personName: data.personName,
                      ),
                    );
                  },
                  // orderBy is compulsary to enable pagination
                  query: firebaseFirestore
                      .collection('Users')
                      .doc(authController.userModel.value.id)
                      .collection('MyMatches')
                      .orderBy('id'),
                  itemBuilderType: PaginateBuilderType.listView,
                ),

can't add a video here, so adding a drive link: https://drive.google.com/file/d/1uLbJPF_CPlBii_sd75tjpuhCDoLGXiHW/view?usp=sharing