binary 3.0.1 copy "binary: ^3.0.1" to clipboard
binary: ^3.0.1 copied to clipboard

Utilities for accessing binary data and bit manipulation in Dart and Flutter

example/main.dart

// ignore_for_file: avoid_print
import 'package:binary/binary.dart';

void main() {
  // Using extension methods.
  //                  String            int
  //                  vvvv vvvvvvvvvvvvvvvv
  print('0111' '1111'.bits.signedRightShift(5, 8));

  // Using boxed types.
  final int8 = Int8('0111' '1111'.bits);
  // Note we did not need to pass in the length, it is provided by the class.
  print(int8.signedRightShift(5));

  // Using bit patterns.
  final $01V = BitPatternBuilder(const [
    BitPart.zero,
    BitPart.one,
    BitPart.v(1, 'V'),
  ]).build();
  print($01V.matches('011'.bits)); // true
  print($01V.capture('011'.bits)); // [1]

  // Alternative bit pattern.
  final $01Vs = const BitPatternBuilder.parse('01V').build();
  print($01V == $01Vs); // true
}
23
likes
140
points
10.9k
downloads

Publisher

verified publisherlurey.dev

Weekly Downloads

Utilities for accessing binary data and bit manipulation in Dart and Flutter

Documentation

API reference

License

MIT (license)

Dependencies

matan, meta

More

Packages that depend on binary