json_cache
Json Cache is an object-oriented package to serve as a layer on top of local storage packages - packages that persist data locally on the user's device -, unifying them as an elegant cache API.
In addition, this package gives the programmer great flexibility; it provides a set of classes that can be selected and combined in various ways to address specific caching requirements.
Why Json?
- Because most of the local storage packages available for Flutter applications
use json as the data format. - There is an one-to-one relationship between the Dart's built-in type
Map<String, dynamic>
and json, which makes json encoding/decoding a
trivial task.
Getting Started
JsonCache
- the core interface of this package - represents the concept of
cached data. It is defined as:
It's reasonable to consider each cache entry (pair of key/data) as a group of
related data. Thus, it is expected to cache user data in groups, in which a key
represents the name of a single group of data. Example:
Above the 'profile' key is associated with the group of profile related data;
'preferences', with preferences data.