简体   繁体   English

如何在 flutter 中对 firestore 数据进行分页

[英]how to paginate firestore data in flutter

I want to make pages like 1,2,3 from firestore documents.我想从 firestore 文档制作像 1,2,3 这样的页面。 But don't know what to do!但是不知道怎么办!

So I need pagination functionality like this:所以我需要这样的分页功能:

  • if the total number of documents in the collection is 26 then it should be divided into 3 pages, as 0-9, 11-19, 20- 26 documents如果集合中的文档总数为 26,则应将其分为 3 页,如 0-9、11-19、20-26 文档
  • when I click on page no 2 it should fetch 11-19 documents.当我点击第 2 页时,它应该获取 11-19 个文档。

So here I also need to find how many documents are there so I can make pages (like 1,2,3) from that所以在这里我还需要找到有多少文档,这样我就可以从中制作页面(如 1、2、3)

What I tried我试过的

  • I tried firebase's official doc firebase query cursor我试过firebase的官方文档firebase 查询 cursor
  • I also tried the paginate_firestore plugin (but It is not compatible with my requirement)我也试过paginate_firestore插件(但它不符合我的要求)
  • If I am on the 1st page and go to the 3rd page directly, it should fetch 21-26 records (as per example given above)如果我在第一页和 go 直接到第三页,它应该获取 21-26 条记录(按照上面给出的例子)

What I want我想要的是

  • for example: when we search in google, at bottom of the page there are pages as (1,2,3 more) so I want similar to this例如:当我们在谷歌中搜索时,页面底部有页面(1,2,3 更多)所以我想要类似于此

May be help you paginate_firestore package.可能会帮助你paginate_firestore package。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM