CallbackAssetLoader class

Convenience class that extends FileAssetLoader and allows you to register a callback for loading Rive assets.

The callback will be called for each asset that needs to be loaded manually. See RiveFile for additional options. Which assets are embedded are defined within the Rive editor.

This callback will be triggered for any referenced assets.

Set loadCdnAssets to false to disable loading assets from the Rive CDN.

Example usage:

Loading from assets. Here only assets marked as referenced will trigger the callback.

final riveFile = await RiveFile.asset(
 'assets/asset.riv',
 loadCdnAssets: true,
 assetLoader: CallbackAssetLoader(
   (asset, bytes) async {
     final res =
         await http.get(Uri.parse('https://picsum.photos/1000/1000'));
     await asset.decode(Uint8List.view(res.bodyBytes.buffer));
     return true;
   },
 ),
);
Inheritance

Constructors

CallbackAssetLoader(Future<bool> callback(FileAsset asset, Uint8List? embeddedBytes))

Properties

callback Future<bool> Function(FileAsset asset, Uint8List? embeddedBytes)
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

load(FileAsset asset, Uint8List? embeddedBytes) Future<bool>
override
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