asset static method

Future<RiveFile> asset(
  1. String bundleKey,
  2. {AssetBundle? bundle,
  3. FileAssetLoader? assetLoader,
  4. bool loadCdnAssets = true,
  5. ObjectGenerator? objectGenerator}
)

Imports a Rive file from an asset bundle.

Default uses rootBundle from Flutter. Provide a custom bundle to load from a different bundle.

Provide an assetLoader to load assets from a custom location (out of band assets). See CallbackAssetLoader for an example.

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

Whether an assets is embedded/cdn/referenced is determined by the Rive file - as set in the editor.

Loading assets documentation: https://help.rive.app/runtimes/loading-assets

Whether an assets is embedded/cdn/referenced is determined by the Rive file - as set in the editor.

Implementation

static Future<RiveFile> asset(
  String bundleKey, {
  AssetBundle? bundle,
  FileAssetLoader? assetLoader,
  bool loadCdnAssets = true,
  ObjectGenerator? objectGenerator,
}) async {
  final bytes = await (bundle ?? rootBundle).load(
    bundleKey,
  );

  return _initTextAndImport(
    bytes,
    assetLoader: assetLoader,
    loadCdnAssets: loadCdnAssets,
    objectGenerator: objectGenerator,
  );
}