Utilities for working with binary data and bit manipulation in Dart.
NOTE: Unless otherwise noted, all functionality is based around treating bits as little endian, that is in a 32-bit integer the leftmost bit is 31 and the rightmost bit is 0
This library supports an
Integral data type for fluent bit manipulation:
print(uint8.toBinaryPadded(196)); // '11000100'
Because of Dart's ability to do advanced inlining in both the Dart VM and
dart2js, this library should perform well and be extremely easy to use for most
use cases. For example, it's used in an
This library has a combination of top-level methods, and instance methods of
Integral data types (see below). For example there are two ways
to clear (set to
0) a bit:
// Sets the 0th bit in an (int) bits to 0 bits = clearBit(bits, 0)
However, this will not do range validation. Use
// Sets the 0th bit in a uint32 to 0. // In dev-mode, if either bits or `n` is out of range it throws. bits = uint32.clearBit(bits, 0);
See the dartdocs for more about the API.
signExtendas a method to
uint128only had a length of 64.
Add this to your package's pubspec.yaml file:
dependencies: binary: "^0.1.3"
You can install packages from the command line:
$ pub get
$ flutter packages get
Alternatively, your editor might support
pub get or
flutter packages get.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
|0.1.3||May 15, 2017|
|0.1.2||Mar 19, 2017|
|0.1.1||Mar 18, 2017|
|0.1.0||Feb 19, 2017|
|0.0.4||Feb 11, 2017|
|0.0.3||Feb 9, 2017|
|0.0.2||Feb 9, 2017|
|0.0.1||Feb 8, 2017|
|0.0.0||Feb 7, 2017|
We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Detected platforms: Flutter, web, other
No platform restriction found in primary library
Fix analysis and formatting issues.
Analysis or formatting checks reported 3 errors.
Strong-mode analysis of
lib/binary.dartfailed with the following error:
line: 114 col: 10
The expression in an assert must be of type 'bool'.
Package is getting outdated.
The package was released 57 weeks ago.
The description is too short.
Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.
Package is pre-v1 release.
While there is nothing inherently wrong with versions of
0.*.*, it usually means that the author is still experimenting with the general direction API.
Maintain an example.
Create a short demo in the
example/directory to show how to use this package. Common file name patterns include:
example.dartor you could also use