leb128 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 56

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 pub get

Alternatively, your editor might support flutter pub 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';
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 Apr 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Maintenance suggestions

Package is getting outdated. (-12.88 points)

The package was last published 58 weeks ago.


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