loadBuffer method

  1. @override
Future<ImmutableBuffer> loadBuffer(
  1. String key
)
override

Retrieve a binary resource from the asset bundle as an immutable buffer.

Throws an exception if the asset is not found.

Implementation

@override
// This is an override on Flutter greater than 3.1
// ignore: override_on_non_overriding_member
Future<ImmutableBuffer> loadBuffer(String key) async {
  final span = _hub.getSpan()?.startChild(
        'file.read',
        description: 'AssetBundle.loadBuffer: ${_fileName(key)}',
      );

  span?.setData('file.path', key);

  ImmutableBuffer data;
  try {
    data = await _loadBuffer(key);
    _setDataLength(data, span);
    span?.status = SpanStatus.ok();
  } catch (exception) {
    span?.throwable = exception;
    span?.status = SpanStatus.internalError();
    rethrow;
  } finally {
    await span?.finish();
  }
  return data;
}