zstandard_cli 1.4.2 copy "zstandard_cli: ^1.4.2" to clipboard
zstandard_cli: ^1.4.2 copied to clipboard

CLI implementation of zstandard. For desktops.

pub package

zstandard_cli #

The command-line implementation of zstandard.

Zstandard (zstd) is a fast compression algorithm developed by Meta (formerly Facebook) for real-time scenarios. It provides a flexible range of compression levels, enabling both high-speed and high-compression-ratio options. This makes it ideal for applications needing efficient data storage, transmission, and backup solutions.

zstandard_cli is a Dart package that binds to the high-performance Zstandard compression library, enabling both in-code and command-line compression and decompression. It leverages FFI to directly access native Zstandard functionality, allowing efficient data processing in Dart applications, from in-memory data compression to file handling via the CLI.

Available on macOS, Windows, and Linux desktops only.

macOS Windows Linux
x64 ✔️ ✔️ ✔️
arm64 ✔️ ✔️ ✔️
Precompiled Yes Yes Yes

Note: This is a pure Dart package for desktop usage. For Flutter, please see the zstandard plugin.

Basic Usage #

void main() async {
  var cli = ZstandardCLI();

  final originalData = Uint8List.fromList([...]);

  final compressed = await cli.compress(originalData, compressionLevel: 3);

  final decompressed = await cli.decompress(compressed ?? Uint8List(0));
}

With extensions:

void main() async {
  final originalData = Uint8List.fromList([...]);

  final compressed = await originalData.compress(compressionLevel: 3);

  final decompressed = await compressed.decompress();
}

CLI Usage #

dart run zstandard_cli:compress any_file 3

dart run zstandard_cli:decompress any_file.zstd

API #

  • ZstandardCLI() — Creates a CLI instance. The native library is loaded once per process.
  • compress(Uint8List data, {int compressionLevel = 3}) — Compresses data (level 1–22). Returns compressed bytes or null.
  • decompress(Uint8List data) — Decompresses zstd-compressed data. Returns decompressed bytes or null.
  • getPlatformVersion() — Returns a string like "macOS 14.0" or "Windows 10".

Extensions on Uint8List?: compress({int compressionLevel = 3}) and decompress(); they return null when the receiver is null.

Testing #

From the package directory:

dart test

Tests run only on supported platforms (macOS, Windows, Linux). They cover small/large/empty data, compression levels, and null-safe extensions.

Troubleshooting #

  • Library not found: Ensure you are on macOS, Windows, or Linux (x64 or arm64). Update the package with dart pub upgrade zstandard_cli.
  • Compress/decompress returns null: Check that input is valid; for decompress, ensure the data is a complete zstd frame.

See the documentation for more.


The images provided below illustrate how to use zstandard_cli for compression and decompression on different platforms.

1
likes
0
points
205
downloads

Publisher

verified publishervyp.dev

Weekly Downloads

CLI implementation of zstandard. For desktops.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

ffi, path, platform, zstandard_native

More

Packages that depend on zstandard_cli