AssetKey<T> class

One loadable asset's identity: which asset this is, and nothing else.

Identity is (T, source) - the payload type and where the bytes come from. Nothing about the shape or value of the decoded asset belongs here. An image's pixel size is discovered by decoding it (AssetInfo); how a sprite samples it is a property of the sprite. Both used to live on the key, and both were wrong: a build pipeline that repacks or recompresses an asset would have been rewriting its identity.

Plain, immutable, sendable data with a phantom type parameter - it makes nothing and fills nothing. That is what lets a key cross Isolate.spawn while the decoded payload, which owns a ui.Image or a native handle, stays on the copy that made it.

Instantiable as-is; subclass only to override loader:

const AssetKey<Texture>(BundleSource('player.png'))
Implementers
Annotations

Constructors

AssetKey(AssetSource source)
const

Properties

debugLabel String
Diagnostics only - what an "asset was never loaded" or "asset was never declared" message names this asset by.
no setter
hashCode int
The hash code for this object.
no setterinherited
loader AssetLoader<T>
What turns this key's bytes into a T.
no setter
payloadType Type
The payload type this key names, as a runtime value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
source AssetSource
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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