AssetSources class final
Which AssetSource a path names, by its scheme.
AssetSource was already open; what was closed is the path. A level
names models/crate.glb, and the loader that reads it decides — the
asset bundle, the checkout on disk — with nothing in between a game could
add to. A path with a scheme, pak:models/crate.glb, now goes to whatever
was registered for pak: an archive, a network cache, a database. A path
without one goes where it always went, to the fallback the caller names.
A table rather than a registry the isolate reads, and that is why it works where a registry of sources would not: the source is made here, on the calling isolate, and what crosses to the one that decodes is the source itself — sendable, as AssetSource says it must be.
A scheme is two or more of lower-case letters, digits, +, - and .,
starting with a letter, so a Windows drive (C:) is a path and not a
scheme.
Constructors
-
AssetSources([Map<
String, AssetSourceFactory> schemes = const {}]) -
A table holding
schemes.
Properties
Methods
-
add(
String scheme, AssetSourceFactory make) → Registration -
Makes
makeanswer forschemeuntil theRegistrationit answers is cancelled, or remove. Throws an ArgumentError for a scheme that is not one, and aNameTakenExceptionfor one already taken. -
handles(
String path) → bool -
Whether
path's scheme has a source here. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
String scheme) → void -
Takes
schemeout again, as cancelling what add answered does. Nothing for a scheme nobody added. -
resolve(
String path, {required AssetSourceFactory fallback}) → AssetSource -
The source for
path: its scheme's, given the path afterscheme:, orfallback's, given the whole path, when it has no scheme known here. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
reservedSchemes
→ const Set<
String> -
The schemes the platform and the engine read themselves, which a
plugin from outside may not take: a source registered for one is asked
before the fallback, so it would take every such load away from the
engine, and a scheme the engine adds in a minor (
hub) would stop an application at start with "already has a source".