ResourceGroup class Assets and loading
Tracks a set of in-flight resource loads so a scene can wait for all of them before it is shown, and report aggregate progress while they run.
Every loader in Flutter Scene returns a Future that completes only once
the resource and its dependencies are decoded and resident on the GPU, so
a completed future means "ready to render this frame". A ResourceGroup
collects those futures, exposes a progress value for a loading bar, and
completes ready once they have all settled. Pass one to a SceneView
(via its loading argument) to hold the scene off-screen behind a loading
widget until it is fully assembled, instead of drawing it half-built.
final loading = ResourceGroup();
final terrain = loading.add(loadScene('terrain.fscene'));
final env = loading.add(
EnvironmentMap.fromEquirectImageAsset(assetPath: 'sky.hdr'),
);
loading.addAll([
Node.fromGlbAsset('player.glb'),
Texture2D.fromAsset('coin.png'),
]);
// Drive a progress bar from loading.progress, or just await:
await loading.ready;
scene.add(await terrain);
progress counts completed loads over the total tracked, so it can jump backward if you add more loads after it has advanced. Track every load up front (before reading progress) to avoid that.
Constructors
- ResourceGroup()
- Creates an empty group. A group with nothing tracked is immediately isReady, and its ready future is already complete.
Properties
- completed → int
-
The number of tracked loads that have settled.
no setter
-
failures
→ List<
Object> -
The errors from any tracked loads that failed, in completion order.
no setter
- hasFailures → bool
-
Whether any tracked load failed.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isReady → bool
-
Whether every tracked load has settled.
no setter
-
progress
→ ValueListenable<
double> -
Fraction of tracked loads that have settled, in the range 0 to 1.
no setter
-
ready
→ Future<
void> -
Completes once every load tracked so far has settled (succeeded or
failed). Never throws; inspect failures for any errors.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- total → int
-
The number of loads tracked so far.
no setter
Methods
-
add<
T> (Future< T> load) → Future<T> -
Tracks
loadand returns it unchanged, so the call reads inline: -
addAll(
Iterable< Future< loads) → voidObject?> > -
Tracks each of
loads. Convenience for calling add in a loop when you do not need the individual futures back. -
dispose(
) → void - Releases the progress notifier. Call when the group is no longer used; after disposal the group must not be added to or listened on.
-
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