英文:
FlutterFlow - Content Pagination with Firestore
问题
我目前正在使用FlutterFlow创建一个应用程序,该应用程序从Firestore加载各种每日新闻项目。
每日消息在Firestore中的结构如下:
- 标题(String)
- 描述(String)
- 图像(Image)
- 内容(Array)
- 类型(String)[文本,图像或分页符]
- 值(String)
内容数组中包含许多文本和图像。
读者应该只收到内容数组的特定部分。一旦他们阅读了这部分内容,就必须点击下一个按钮。只有这样,才会加载更多内容。
我想使用FlutterFlow将不同的条目从数组加载到一个单元中,直到出现分页符类型。
然后读者应该按下“下一个”按钮,将加载下一部分内容,直到出现下一个分页符类型。
目前,整个内容都被加载。对我来说,这和无限滚动都不是选项。
是否有人之前遇到过类似的问题,或者可以帮助我解决这个问题?提前感谢!
英文:
I am currently creating an app with FlutterFlow that loads various daily news items from Firestore.
Each daily message is structured in Firestore like this:
- Title (String)
- Description (String)
- Image (Image)
- Content (Array)
- Type (String) [Text, Image or PageBreak]
- Value (String)
The content array is very filled with many texts and images.
Readers should receive only a certain part of the content array. Once they have read this part, the next button must be clicked. Only then will more content be loaded.
I want to use FlutterFlow to load different entries from the array to a unit, up to the type PageBreak.
Then the readers should press the Next button and the next part of the content, up to the next type PageBreak, will be loaded.
Currently, the whole content is loaded. This and also Infinity Scroll are no options for me.
Has anyone had a similar problem before or can help me with this?
Thanks in advance
答案1
得分: 1
当您在Web、iOS或Android上使用Firestore客户端SDK执行查询时,您会得到完整的文档作为结果。没有办法只获取文档的一部分。因此,您无法仅获取Content
数组的一部分,要么获取整个文档,要么什么都不获取。
如果您不想下载包含Content
数组的整个文档,那么您应该将该数组从文档中提取出来,为数组的每个部分创建一个单独的文档。然后,您可以简单地进行分页处理结果。
如果您需要分页显示存在于Content
数组中的数据,而不创建额外的文档,那么您必须根据您的约束条件自己创建这样的机制。
英文:
When you perform a query in Firestore using the client SDK for web, iOS, or Android, you get as a result full documents. There is no way you can only get a slice of a document. So you cannot get only a portion of the Content
array, it's the entire document or nothing.
If you don't want to download the entire document with the Content
array, then you should get that array out of the document, and create a separate document for each part of the array. Then you can simply paginate the results.
If you need to paginate the data that exists inside the Content
array, without creating additional documents, then you have to create such a mechanism yourself based on the constraints you want.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论