Luso1218
Luso1218

Reputation: 55

Cacheing API Results using Flutter an Hive

What is the proper way to cache API results using Hive?

The current way I plan to implement it is using the request URL as the key and the returned data as the body.

Is there a proper way to do this more production friendly? I can't find a tutorial as most tutorials are abstracted by using another package that takes care of this for them or a tutorial uses a different package.

Upvotes: 4

Views: 2509

Answers (1)

Shashiben
Shashiben

Reputation: 230

In order to cache rest API data, you can use hive which is a No-SQL database and is easier to use and faster to retrieve and is faster than shared preferences and sqflite.

For more details you can check this repo to understand better : https://github.com/shashiben/Anime-details

And you can read this article: https://medium.com/flutter-community/flutter-cache-with-hive-410c3283280c

The code is written cleaner and is architectures by using stacked architecture. Hope this answer is helpful to you

Upvotes: 5

Related Questions