AssetsCache class

A class that loads, and caches files.

Files are addressed by their full path, exactly as declared in the pubspec.yaml, for example assets/levels/level1.json.

Constructors

AssetsCache({AssetBundle? bundle})

Properties

bundle ↔ AssetBundle
The AssetBundle from which assets are loaded. defaults to Flame.bundle.
getter/setter pair
cacheCount → int
Returns the number of files in the cache.
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear(String file) → void
Removes the file from the cache.
clearCache() → void
Removes all the files from the cache.
fromCache<T>(String fileName) → T
This method provides synchronous access to cached assets, similar to AssetsCache.fromCache.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readBinaryFile(String fileName, {String? package}) → Future<Uint8List>
Reads a binary file from the assets.
readFile(String fileName, {String? package}) → Future<String>
Reads a file from the assets.
readJson(String fileName, {String? package}) → Future<Map<String, dynamic>>
Reads a json file from the assets.
toString() → String
A string representation of this object.
inherited

Operators

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