Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit total items to be loaded #147

Open
ghost opened this issue Aug 22, 2022 · 1 comment
Open

Limit total items to be loaded #147

ghost opened this issue Aug 22, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 22, 2022

First of all this package is very handy and I use it in several projects, so I appreciate it.

My intention is to load 5 new documents each time user swipes the first 5 documents, so I have this attribute on my widget itemsPerPage: 5,. But my main goal is to restrict some users the maximum amount of documents they can load. Like in a query you would normally use in a FutureBuilder;

child: FutureBuilder<QuerySnapshot>(
          future: FirebaseFirestore.instance
              .collection('Upcoming')
              .orderBy('ReleaseTimestamp')
              .where('ReleaseTimestamp', isGreaterThan: Timestamp.now())
              .limit(3) // This actually only loads 3 documents totally
              .get(),

But when trying to do the exact same procedure with this package the limit method used in the query is ignored;

class ExampleWidget extends StatelessWidget {
  const ExampleWidget ({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return PaginateFirestore(
      pageController: PageController(viewportFraction: 0.85),
      scrollDirection: Axis.horizontal,
      itemsPerPage: 5,
      itemBuilderType: PaginateBuilderType.pageView,
      query: FirebaseFirestore.instance
          .collection('Menu')
          .orderBy('Timestamp', descending: true)
          .limit(10), // ! THIS DOESN'T WORK
      itemBuilder: (context, snapshot, index) {
        return Text(snapshot.toString());
      },
    );
  }
}

Any idea how can I limit the total queried documents while also using the pagination? Like I want some users to load max 100 documents but paginate these 100 documents 20 by 20.

@RoyalCoder88
Copy link

@appleist-a bump for this idea, will be a great feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant