I want to read a zip file which is in my asset folder. I do not want to write the unpacked version to storage, but to directly process the zip file stream. The zip file only contains one file (which is retrieved by archive.first). However, I fail to convert a ByteData to an InputStream.
Is this possible?
import 'dart:convert';
import 'dart:typed_data';
import 'package:archive/archive.dart';
@override
void initState() {
super.initState();
DefaultAssetBundle.of(context)
.load("assets/data/WZ2008.zip")
.then((ByteData value) {
Uint8List wzzip =
value.buffer.asUint8List(value.offsetInBytes, value.lengthInBytes);
final archive = ZipDecoder().decodeBuffer(???); <- How to solve this?
ArchiveFile a = archive.first;
WZ2008 = jsonDecode(a.content)["Inhalt"]
.map<String>((e) => e["Stichwort"].toString())
.toList();
});
}
Thanks!