简体   繁体   English

从Flutter中的数据库和网络分页数据

[英]Paging data from database and network in Flutter

I'm pretty new to Flutter development, coming from an Android background.我是 Flutter 开发的新手,来自 Android 背景。 I want to implement the following pattern like it is commenly used with the Paging 3 jetpack library:我想实现以下模式,就像它通常与 Paging 3 jetpack 库一起使用一样:

UI <-------> Repo --- Out of data ---> Network
               ^                          |
               |                          |
               ---------- Save ------------ 

I also want to support paging in both directions.我还想支持双向分页。 Anything I have seen so far on pub.dev is only paging in one direction.到目前为止,我在 pub.dev 上看到的任何内容都只是朝一个方向分页。 Do I have to implement this pattern for myself or is there already a library for this?我必须为自己实现这个模式还是已经有一个库?

Since the data is from a database via network, you could use dio to do network requests and dio_http_cache to cache the data.由于数据是通过网络从数据库中获取的,您可以使用dio进行网络请求,使用dio_http_cache缓存数据。 With forceRefresh option enabled, user would see the cached data when they don't have internet access and see fresh data when they have internet access.启用forceRefresh 选项后,用户将在无法访问 Internet 时看到缓存数据,并在访问 Internet 时看到新数据。

This is the closest at this time to what you need.这是目前最接近您需要的。

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

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