betto_zstd 0.1.0-dev.3 copy "betto_zstd: ^0.1.0-dev.3" to clipboard
betto_zstd: ^0.1.0-dev.3 copied to clipboard

A Zstandard (Zstd) compression library for Dart. Supports native platforms via FFI and the web platform via an Emscripten-compiled WASM module.

example/main.dart

// Copyright 2026 The Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import 'dart:typed_data';
import 'package:betto_zstd/betto_zstd.dart';

Future<void> main() async {
  await ZstdSimple.init(); // no-op on native; required on web before first use

  // Create a ZstdSimple instance with a specific compression level (default is 3)
  final zstd = ZstdSimple(level: 3);

  // Data to compress
  final data = Uint8List.fromList([1, 2, 3, 4, 5, 1, 2, 3, 4, 5]);

  // Compress
  final compressed = zstd.compress(data);
  print('Compressed size: ${compressed.length}');

  // Decompress
  final decompressed = zstd.decompress(compressed);
  print('Decompressed size: ${decompressed.length}');
}
0
likes
160
points
--
downloads

Documentation

API reference

Publisher

verified publisherbettongia.com

A Zstandard (Zstd) compression library for Dart. Supports native platforms via FFI and the web platform via an Emscripten-compiled WASM module.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#compression #zstd

License

Apache-2.0 (license)

Dependencies

code_assets, collection, ffi, hooks, logging, native_toolchain_c

More

Packages that depend on betto_zstd