leb128 1.0.0

  • README.md
  • Example
  • Installing
  • Versions
  • 52

LEB128 Encoder/Decoder #

This package offers easy-to-use methods that let you encode and decode LEB128 data. LEB128, which is short Little Endian Base 128, is a code compression algorithm that is used in a variety of file formats. The most well-known are WebAssembly's binary .wasm and Android's .dex files.

Usage #

  • You can call the Leb128.encodeSigned() method to convert a Dart int value into an LEB128 list of bytes. The list is a Uint8List object. Use this method for both positive and negative values.

  • You can call the Leb128.encodeUnsigned() method to convert a Dart int value, which is positive, into an LEB128 list of bytes.

  • You can call the Leb128.decodeSigned() method to convert a Uint8List object into a Dart int value. Use this method for signed LEB128 integers only.

  • You can call the Leb128.decodeUnsigned() method to convert a Uint8List object into a Dart int value. Use this method for unsigned LEB128 integers only.

This package also offers two utility methods namedLeb128.decodeVarint7() and Leb128.decodeVaruint7(), which are easier to use if you need to convert a single byte of data.

[1.0.0] - 20th February 2019

  • Improved encoding logic

[0.9.1] - 20th February 2019

  • Improved example

[0.9.0] - 20th February 2019

  • Initial release.


import 'package:leb128/leb128.dart';

void main() {
  var input = -9019283812387;

  // Encode the negative number shown above
  var output = Leb128.encodeSigned(input);

  // Print the individual bytes of the encoded
  // number in hex
  output.forEach((x) {

  // Decode the LEB128 number into an ordinary integer and
  // print it

  // Quickly decode a varuint7

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  leb128: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:leb128/leb128.dart';
Version Uploaded Documentation Archive
1.0.0 Feb 20, 2019 Go to the documentation of leb128 1.0.0 Download leb128 1.0.0 archive
0.9.1 Feb 20, 2019 Go to the documentation of leb128 0.9.1 Download leb128 0.9.1 archive
0.9.0 Feb 20, 2019 Go to the documentation of leb128 0.9.0 Download leb128 0.9.0 archive
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]
Learn more about scoring.

We analyzed this package on Mar 6, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.3.3


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies