I'm trying to extract files from an archive but I'm getting this error.
E/flutter (31571): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FileSystemException: Cannot open file, path = 'assets/res.zip' (OS Error: No such file or directory, errno = 2)
My code. https://pub.dev/packages/archive/example
final bytes = File('assets/res.zip').readAsBytesSync();
final archive = ZipDecoder()
.decodeBytes(bytes, verify: true, password: '123');
// Extract the contents of the Zip archive to disk.
for (final file in archive) {
final filename = file.name;
if (file.isFile) {
final data = file.content as List<int>;
File('out/' + filename)
..createSync(recursive: true)
..writeAsBytesSync(data);
} else {
Directory('out/' + filename).create(recursive: true);
}
}
pubspec.yaml
assets:
- assets/
- assets/res.zip