ZipWriter class final
Builds a ZIP archive whose bytes depend only on its files' paths and contents.
Entries are sorted by path, every timestamp is 1980-01-01 00:00, names
are flagged UTF-8, every file is recorded as Unix mode 0100644 (or
0100755 when added as executable), and each file is stored or
DEFLATE-compressed, whichever is smaller. So packing the same folder
twice — on any platform — gives the same SHA-256, which is what lets a
catalog pin it.
It refuses what ZipArchive.read would refuse: unsafe paths, two
paths one file system could see as one (SafePaths.caseKey), and a
path used both as a file and as a folder.
final zip = ZipWriter()
..add('pubspec.yaml', pubspec)
..add('tool/build.sh', script, executable: true)
..add('assets/knight.png', png);
final bytes = zip.close();
Properties
Methods
-
add(
String path, List< int> bytes, {bool executable = false}) → void -
Adds a file at
path(checked by SafePaths) holdingbytes;executablerecords it as runnable on Linux and macOS. -
close(
) → Uint8List - The archive's bytes. The writer takes no more files.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited