flutter_media_cache 2.0.1
flutter_media_cache: ^2.0.1 copied to clipboard
A powerful Flutter package for caching images and videos with customizable expiration time and automatic cache management.
Changelog #
2.0.1 — 2026-06-25 #
✨ New Features #
- Web platform support — package now works on all 6 Flutter platforms: Android · iOS · Web · macOS · Windows · Linux.
MediaCacheManager.formatBytes(int)utility for human-readable cache sizes.MediaCacheManager.totalCacheSizegetter (memory bytes on web, disk bytes on native).
🔧 Improvements #
CachedVideoon web usesVideoPlayerController.networkUrl()automatically — no code changes needed in calling code.- All disk I/O isolated behind
PlatformStorageconditional-import abstraction;dart:iois never imported on web. CacheIndexrewritten to bedart:io-free (serialises viaUint8List).- Orphaned file cleanup (
purgeOrphans) runs at startup on native platforms.
🐛 Bug Fixes #
- Fixed: Package failed to compile on Flutter Web due to
dart:ioimports inmedia_cache_manager.dartandcached_video.dart. - Fixed:
CachedVideocrashed on web with "Video file path unavailable". - Fixed: pub point issues.
2.0.0 — 2026-06-25 #
⚠️ Breaking Changes #
- Complete rewrite — public API is redesigned. See README for migration guide.
FlutterMediaCacheclass replaced byMediaCacheManagersingleton.CachedImageconstructor parameters reorganised (imageUrlreplacesurl).
✨ New Features #
- Priority download queue —
DownloadPriority.high/normal/lowper request. - Request deduplication — duplicate URLs share one in-flight download.
- Exponential-backoff retry — configurable via
CacheConfig.maxRetries. - Per-download progress stream —
Stream<DownloadProgress>with bytes received. - Conditional HTTP GET —
ETag/Last-Modified/If-None-Matchsupport. - Smart LRU eviction — separate memory (item count) and disk (byte size) limits.
- Preloading API —
MediaCacheManager.instance.preloadAll([...]). - Cancellation —
cancelDownload(url)stops queued or in-flight tasks. CachedVideowidget with built-in progress indicator and playback controls.DownloadProgressBuilderfor fully custom progress UIs.CacheManagerProviderInheritedWidgetfor dependency injection.CacheStats— hit count, miss count, eviction count, hit rate, total size.- Atomic index persistence — write-then-rename prevents index corruption.
- Orphan file cleanup — dangling files not in the index are removed on startup.
🔧 Improvements #
- Cache keys now use SHA-256 (not MD5) for collision-resistance.
- Download engine lives on the main isolate with
async/await— no Isolate overhead for small payloads, correct Flutter API access. CacheConfig.copyWith()for easy per-screen overrides.- Debounced index writes (2 s) — avoids disk thrash on rapid requests.
ResizeImagesupport inCachedImageto reduce decoded memory footprint.
🐛 Bug Fixes #
- Fixed: Concurrent requests for the same URL triggered multiple downloads.
- Fixed: Memory cache could grow unboundedly.
- Fixed: Download failures were silently swallowed.
- Fixed: Stale index entries for missing files caused errors.
[1.x.x] — Legacy #
See Git history for 1.x changes.