extract static method
Implementation
static Future<Stream<List<int>>> extract(
File file, {
required final int entryStart,
required final int entryEnd,
required final int compressionMethod,
IntRange? range,
}) async {
if (range == null) {
Stream<List<int>> stream = file.openRead(entryStart, entryEnd);
if (compressionMethod == 0) return stream;
if (compressionMethod == 8) return stream.transform(zlibDecoder);
}
if (range != null) {
if (compressionMethod == 0) {
int start = min(entryStart + range.start, entryEnd);
int end = min(entryStart + range.length, entryEnd);
return file.openRead(start, end);
}
if (compressionMethod == 8) {
return file
.openRead(entryStart, entryEnd)
.transform(zlibDecoder)
.transform(_RangeStreamTransformer(range));
}
}
throw UnsupportedError('Unsupported compress method: $compressionMethod');
}