Cached Storage

Visit the documentation for more information.

A Storage addon to the CachedQuery package.

Built on top of Sqflite.


  • Persist queries to disk
  • Accepts any json serializable data.

Getting started

Initialized cached query with the storage interface. This must be initialized before any query is called.

void main() async {
    storage: await CachedStorage.ensureInitialized(),

Queries will then automatically be persisted.


Cached Storage uses jsonEncode to convert the data of a query to json, which is then stored. If you are returning dart objects from the queryFn you will need to serialized the json back into the dart object. To do this, pass a serilizer to the QueryConfig which will be used to turn the stored data back into a dart object.

  key: 'joke',
  config: QueryConfig(
    // Use a serializer to transform the store json to an object.
    serializer: (dynamic json) =>
        JokeModel.fromJson(json as Map<String, dynamic>),
  queryFn: () async {
    final req = client.get(
      headers: {"Accept": "application/json"},
    final res = await req;
    return JokeModel.fromJson(
        jsonDecode(res.body) as Map<String, dynamic>,

Additional information

This package is an addon for Cached Query. For persistent storage take a look at Cached Storage.