Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 841
Luso1218 Avatar asked Oct 23 '25 16:10

Luso1218


1 Answers

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

like image 182
Shashi Msp Avatar answered Oct 25 '25 06:10

Shashi Msp