network static method

Future<RiveFile> network(
  1. String url,
  2. {Map<String, String>? headers,
  3. @Deprecated('Use `assetLoader` instead.') FileAssetResolver? assetResolver,
  4. FileAssetLoader? assetLoader,
  5. bool loadCdnAssets = true,
  6. ObjectGenerator? objectGenerator}
)

Imports a Rive file from a url over HTTP.

Provide headers to add custom HTTP headers to the request.

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> network(
  String url, {
  Map<String, String>? headers,
  @Deprecated('Use `assetLoader` instead.') FileAssetResolver? assetResolver,
  FileAssetLoader? assetLoader,
  bool loadCdnAssets = true,
  ObjectGenerator? objectGenerator,
}) async {
  final res = await http.get(Uri.parse(url), headers: headers);
  final bytes = ByteData.view(res.bodyBytes.buffer);
  return _initTextAndImport(
    bytes,
    assetLoader: assetLoader,
    loadCdnAssets: loadCdnAssets,
    objectGenerator: objectGenerator,
  );
}