network static method
Future<RiveFile>
network(
- String url, {
- Map<
String, String> ? headers, - FileAssetLoader? assetLoader,
- bool loadCdnAssets = true,
- 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,
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,
);
}