load method Null safety

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

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

Throws an exception if the asset is not found.


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.fromParts(<DiagnosticsNode>[
      IntProperty('HTTP status code', response.statusCode),
  final Uint8List bytes = await consolidateHttpClientResponseBytes(response);
  return bytes.buffer.asByteData();