CrossCache class

A cross-platform caching utility for downloading and storing binary data (like images).

It supports various data sources:

  • HTTP/HTTPS URLs
  • Local file paths
  • Flutter asset paths (assets/...)
  • Data URIs (data:...)
  • Base64 encoded strings

Uses a platform-specific Cache implementation (io.dart or html.dart) for persistence and Dio for network requests.

Constructors

CrossCache.new({Dio? dio, BaseOptions? options})
Creates a CrossCache instance.

Properties

hashCode int
The hash code for this object.
no setterinherited
options → BaseOptions?
Optional base options for the internal Dio instance if one is not provided.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

contains(String key) Future<bool>
Checks if the cache contains an entry for the given key.
delete(String key) Future<void>
Removes the cache entry for the given key.
dispose() → void
Disposes resources used by the cache.
downloadAndSave(String source, {Map<String, dynamic>? headers, ProgressCallback? onReceiveProgress}) Future<Uint8List>
Downloads data from the given source and saves it to the cache.
get(String key) Future<Uint8List>
Retrieves the cached byte data for the given key.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
set(String key, Uint8List value) Future<void>
Stores the given byte value in the cache with the specified key.
toString() String
A string representation of this object.
inherited
updateKey(String key, String newKey) Future<void>
Renames a cache entry from key to newKey.

Operators

operator ==(Object other) bool
The equality operator.
inherited