cross_cache
1.1.1, released 2 months ago by flyer.chat
Cross-platform caching library for Flutter using IndexedDB and the file system.
WASM-ready
What it does
A simple cross-platform caching library for Flutter. It automatically manages storage using IndexedDB on the web and the file system on mobile and desktop platforms, and uses Dio for network requests.
AI-written summary of version 1.1.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to cache network resources or images across mobile, desktop, and web.
- You want a drop-in ImageProvider replacement that uses local cache.
- You need direct key-value cache operations like get, set, delete, and contains.
Skip it when
- You need complex relational queries or a robust local database like SQLite.
- You require advanced cache purging strategies like LRU, MRU, or FIFO out of the box.
Strengths
- Cross-platform support utilizing IndexedDB on web and file system on IO platforms.
- Includes a built-in CachedNetworkImage provider for Flutter widgets.
- Supports multiple resource sources including network URLs, assets, data URIs, and base64 strings.
Weaknesses
- Lacks automatic cache purging or maximum size/item count configuration.
- Does not currently support cancellation for downloads in progress.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 5
import 'package:cross_cache/cross_cache.dart';
import 'package:dio/dio.dart';
final cache = CrossCache();
Future<void> loadImageData(String imageUrl) async {
final imageData = await cache.downloadAndSave(imageUrl);
}
// Remember to dispose when done
// cache.dispose();Alternatives
Packages that do the same job and could replace cross_cache.
- flutter_cache_manager
Pick if you need a widely used, mature file caching manager with built-in automatic purging and advanced cache control.
91Compare
Works with
Packages commonly used together with cross_cache: ones it builds on, ones built on it, and its own family.
- cryptocross_cache depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- path_providercross_cache depends on itProvides Flutter APIs to locate common filesystem directories on Android, iOS, macOS, Linux and Windows.
- diocross_cache depends on itA powerful HTTP networking package for Dart and Flutter with interceptors and request cancellation.
- idb_shimcross_cache depends on itCross-platform IndexedDB implementation for Dart and Flutter.
- cross_filecross_cache depends on itAn abstraction to allow working with files across multiple platforms.
- flutter_chat_uiBuilt on cross_cacheA customizable, cross‑platform chat UI widget set for Flutter.
- flyer_chat_image_messageBuilt on cross_cacheImage message widget for Flutter chat apps with cross-platform caching, BlurHash, and ThumbHash.