load method
- String asset
Loads an asset using an XMLHttpRequest
and returns data as ByteData.
Implementation
Future<ByteData> load(String asset) async {
final String url = getAssetUrl(asset);
final HttpFetchResponse response = await httpFetch(url);
if (response.status == 404 && asset == 'AssetManifest.json') {
printWarning('Asset manifest does not exist at `$url` - ignoring.');
return ByteData.sublistView(utf8.encode('{}'));
}
return (await response.payload.asByteBuffer()).asByteData();
}