cachet_image library

A modern, isolate-friendly cached network image package for Flutter.

Provides CachetImage, a drop-in widget for loading and caching network images to disk, with structured error states, stream-based progress reporting, and LRU-based cache eviction.

Classes

CachetCacheFailure
A failure that occurred during cache reading or writing.
CachetCacheManager
Manages on-disk storage for cached image bytes plus a JSON index of metadata used for LRU eviction.
CachetDecodeFailure
A failure that occurred during image decoding.
CachetEntryMeta
Metadata stored alongside cached bytes on disk.
CachetError
Emitted when a load fails. Carries a structured CachetFailure instead of a raw exception so UI code can branch on failure kind.
CachetFailure
Structured failure reasons, as a sealed hierarchy rather than generic exceptions — lets callers pattern-match to decide retry strategy, messaging, etc.
CachetImage
A modern replacement for Image.network with disk caching, structured error states, and full control over loading / placeholder / error UI via builders.
CachetLoaded
Emitted when bytes are available, either from disk cache or a freshly completed network fetch.
CachetLoader
Loads a network image, checking disk cache first, and emits a sequence of CachetStates describing progress.
CachetLoading
Emitted immediately when a load starts, before any bytes exist in memory or on disk.
CachetNetworkFailure
A failure that occurred during a network request.
CachetState
The state of a single image load, emitted over a Stream.

Functions

decodeImageOffMainIsolate(Uint8List bytes) → Future<Image>
Decodes raw image bytes into an ui.Image on a background isolate via compute, keeping large JPEG/PNG decode work off the UI thread.

Typedefs

CachetCacheStats = ({int entryCount, int totalBytes})
Simple typedef using a record to describe cache size, kept separate from CachetEntryMeta since it's a pure value tuple with no serialization needs.