decodeFromBuffer method

Future<MovieEntity> decodeFromBuffer(
  1. List<int> bytes
)

Download animation file from buffer, and decode it.

Implementation

Future<MovieEntity> decodeFromBuffer(List<int> bytes) {
  TimelineTask? timeline;
  if (!kReleaseMode) {
    timeline = TimelineTask(filterKey: _filterKey)
      ..start('DecodeFromBuffer', arguments: {'length': bytes.length});
  }
  final inflatedBytes = archive.ZLibDecoder().decodeBytes(bytes);
  if (timeline != null) {
    timeline.instant('MovieEntity.fromBuffer()',
        arguments: {'inflatedLength': inflatedBytes.length});
  }
  final movie = MovieEntity.fromBuffer(inflatedBytes);
  if (timeline != null) {
    timeline.instant('prepareResources()',
        arguments: {'images': movie.images.keys.join(',')});
  }
  return _prepareResources(
    _processShapeItems(movie),
    timeline: timeline,
  ).whenComplete(() {
    if (timeline != null) timeline.finish();
  });
}