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

All documents are being fetched instead of the number defined by itemsPerPage #124

Closed waqadArshad closed 2 years ago

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,
                      ),
vedartm commented 2 years ago

@waqadArshad Please don't set shrinkWrap to true. It will expand the list internally and calls all the pagination at once. Thanks for using the package and feel free to reopen if you face this issue again.

waqadArshad commented 2 years ago

@waqadArshad Please don't set shrinkWrap to true. It will expand the list internally and calls all the pagination at once. Thanks for using the package and feel free to reopen if you face this issue again.

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

waqadArshad commented 2 years ago

@vedartm @austinn @fer-ri @atrope Can anyone please look into this. I have tried shrink wrap, but it still fetches all the docs and not just the number of docs defined by the itemsPerPage property. Thanks

@waqadArshad Please don't set shrinkWrap to true. It will expand the list internally and calls all the pagination at once. Thanks for using the package and feel free to reopen if you face this issue again.

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