binary library

Utilities for working with binary data and fixed-width integers within Dart.

A spiritual successor to `package:fixnum`, or "what if fixnum still received updates and used modern Dart features, with a focus on being able to manipulate bits and bytes in a way that is both safe and efficient, using extension types heavily to avoid unnecessary object creation.

Note

Unless otherwise noted, all functionality is based on treating bits as little endian, that is, in a 32-bit integer the leftmost bit is 31 and the rightmost bit is 0. This is the same as the default behavior of the Dart SDK.

Classes

BitList
An variant of List<bool> that ensures each bool takes one bit of memory.
IntDescriptor<T>
A descriptor for a fixed-width integer type T.

Extension Types

Int16
A signed 16-bit integer.
Int32
A signed 32-bit integer.
Int8
A signed 8-bit integer.
Uint16
An unsigned 16-bit integer.
Uint32
An unsigned 32-bit integer.
Uint8
An unsigned 8-bit integer.

Extensions

BytesBuilderExtension on BytesBuilder
Additional functionality for BytesBuilder.
IntExtension on int
Additional functionality for any integer, without size restrictions.

Constants

debugCheckUncheckedInRange → const bool
Whether unchecked methods on fixed-width integers assert when out of range.

Properties

debugCheckFixedWithInRange bool
Whether some methods on fixed-width integers assert when out of range.
getter/setter pair

Functions

collectBytes(Stream<List<int>> stream) → (Future<Uint8List>, Future<void> Function())
Collects the bytes of a Stream<List<int>> into a Uint8List.
viewOrCopyAsBytes(List<int> bytesOrBuffer) Uint8List
Returns a Uint8List representation of the given bytesOrBuffer.