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

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
schemes → List<String>
The schemes known, in the order they were added.
no setter

Methods

add(String scheme, AssetSourceFactory make) → Registration
Makes make answer for scheme until the Registration it answers is cancelled, or remove. Throws an ArgumentError for a scheme that is not one, and a NameTakenException for 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 scheme out 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 after scheme:, or fallback'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

Static Methods

schemeOf(String path) → String?
The scheme of path, or null when it has none.

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".