Skip to content
pubscout

flutter_cache

0.1.0, released 6 years ago by an unverified publisher

A wrapper for shared_preferences to cache data with lifetime support.

WASM-readyUnverified publisher
$ flutter pub add flutter_cache
Source repository

What it does

Wraps shared_preferences to simplify storing and loading strings, maps, and lists. It supports setting expiration lifetimes for cached items and retrieving default values if a key does not exist.

AI-written summary of version 0.1.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want a simpler API over shared_preferences for basic caching needs.
  • You need to cache API responses or app data with a time-to-live (TTL) expiration.
  • You work with common data types like String, Map, List<String>, and List<Map>.

Skip it when

  • You need complex relational queries or large-scale local storage (use a database like sqflite or drift instead).
  • You need secure encryption for stored data (use flutter_secure_storage instead).

Strengths

  • Simplifies working with shared_preferences via functional helpers like cache.remember.
  • Supports optional cache lifetimes in seconds.
  • Automatically handles multiple data types including nested maps and lists.

Weaknesses

  • Limited to data types supported by or serializable through shared_preferences.
  • Relies entirely on shared_preferences underneath, inheriting its performance and storage limits.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1
import 'package:flutter_cache/flutter_cache.dart' as cache;

cache.write('key', 'data', 120); 
var value = cache.load('key', 'defaultValue');

Alternatives

Packages that do the same job and could replace flutter_cache.

Works with

Packages commonly used together with flutter_cache: ones it builds on, ones built on it, and its own family.