binary
4.0.0, released 2 years ago by lurey.dev
Utilities for binary data and bit manipulation in Dart.
What it does
Provides fixed‑width integer types and extension‑type based APIs for binary operations, shifting, and overflow‑controlled arithmetic. Includes helpers like BitList and byte‑view utilities.
AI-written summary of version 4.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need precise bit‑level manipulation of integers up to 32 bits.
- You want deterministic overflow handling across debug and release builds.
- You require a pure‑Dart solution that works on all Flutter and web platforms.
Skip it when
- You need 64‑bit or larger integer support.
- You prefer a stable API without recent breaking changes.
- You rely on code‑generation‑based binary serializers.
Strengths
- Works on all Dart/Flutter platforms without native code.
- Offers explicit overflow‑control methods (tryAdd, wrappedAdd, clampedAdd).
- Leverages modern extension types for a clean API.
Weaknesses
- Limited to 32‑bit integers; no built‑in larger types.
- Version 4 introduced breaking changes, removing many older extensions.
- Requires Dart 3.5+ for extension‑type support.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'package:binary/binary.dart';
void main() {
final fixInt = Uint8(0x0C);
print(fixInt.toBinaryString()); // 00001100
final shifted = fixInt.signedRightShift(5);
print(shifted.toBinaryString()); // 00000011
}Alternatives
Packages that do the same job and could replace binary.
- gtk
GTK utilities for Flutter Linux applications, providing settings and application lifecycle helpers.
76Compare - flutter_flavorizr
A utility to easily create and configure application flavors in Flutter.
86Compare - ml_linalg
SIMD-based linear algebra and statistics library for Dart.
80Compare - buffer
Utilities and classes for reading and writing byte buffers and binary data streams.
50Compare
Works with
Packages commonly used together with binary: ones it builds on, ones built on it, and its own family.