3

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.

padaleiana
  • 955
  • 1
  • 14
  • 23
Luso1218
  • 45
  • 3

1 Answers1

5

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

Shashiben
  • 222
  • 2
  • 7