zstandard_macos 1.4.2
zstandard_macos: ^1.4.2 copied to clipboard
macOS platform implementation of zstandard
zstandard_macos #
The macOS implementation of the zstandard Flutter plugin. Uses FFI and the native Zstandard C library.
Installation #
Add the main plugin to your app; this package is included automatically via the federated plugin:
dependencies:
zstandard: ^1.3.29
No extra setup is required for normal use.
Usage #
Use the main zstandard API; the macOS implementation is selected automatically on macOS:
import 'package:zstandard/zstandard.dart';
void main() async {
final zstandard = Zstandard();
final data = Uint8List.fromList([1, 2, 3, 4, 5]);
final compressed = await zstandard.compress(data, 3);
final decompressed = await zstandard.decompress(compressed ?? Uint8List(0));
}
Or use the extension methods:
final compressed = await data.compress(compressionLevel: 3);
final decompressed = await compressed?.decompress();
API #
- ZstandardMacOS() — Creates the macOS platform implementation.
- compress(Uint8List data, int compressionLevel) — Compresses
data(level 1–22). Returns compressed bytes ornull. - decompress(Uint8List data) — Decompresses zstd-compressed data. Returns decompressed bytes or
null. - getPlatformVersion() — Returns a platform identifier string.
Architecture #
This package uses Dart FFI with the zstandard_macos framework (native zstd C library). Supports x64 and arm64 (Apple Silicon).
Testing #
From the package directory:
flutter test
Unit tests that use the native library require the framework to be built (e.g. by building the example macOS app first). Tests are skipped when not running on macOS.
Troubleshooting #
- Library not loaded: Build your app with
flutter build macosor run from the macOS runner so the framework is built and linked. - Wrong architecture: Ensure you are building for the correct target (x64 vs arm64).
See the documentation for more.
