asset_cache 2.0.0 asset_cache: ^2.0.0 copied to clipboard
Load and cache binary asset of any type given a decoder. Built in support for byte data, images, json and text.
asset_cache will load and cache any asset of type
T given a decoder.
It was made as CachingAssetBundle does not cache binary data.
Binary resources (from load) are not cached.
Describe assets in your
assets: - assets/images/ - assets/json/
Create asset cache instances with an optional
basePath to avoid full paths:
final imageCache = ImageAssetCache(basePath: "assets/images/"); final jsonCache = JsonAssetCache(basePath: "assets/json/");
Load and cache assets using
load returns a
final image = await imageCache.load('sprite.png') final json = await jsonCache.load('sprite.json')
AssetCache implementations are included:
Custom AssetCache #
Create a custom asset cache by inheriting from
AssetCache and pass it a
You can also inherit from
GenericCache and override
loadAsset, if you don't want to load from a