load method

  1. @override
Future<ByteData> load (String key)
override

Retrieve a binary resource from the asset bundle as a data stream.

Throws an exception if the asset is not found.

Implementation

@override
Future<ByteData> load(String key) async {
  final HttpClientRequest request = await _httpClient.getUrl(_urlFromKey(key));
  final HttpClientResponse response = await request.close();
  if (response.statusCode != HttpStatus.ok)
    throw FlutterError(
      'Unable to load asset: $key\n'
      'HTTP status code: ${response.statusCode}'
    );
  final Uint8List bytes = await consolidateHttpClientResponseBytes(response);
  return bytes.buffer.asByteData();
}