decodeUnsigned static method

BigInt decodeUnsigned(
  1. List<int> bytes
)

De-Serializes a leb128 unsigned bytes into a BigInt.

Implementation

static BigInt decodeUnsigned(List<int> bytes) {
    String bitstring = '';
    bitstring += bytes[bytes.length-1].toRadixString(2);
    for (int byte in bytes.reversed.toList().sublist(1)) {
        String bitstring_7_part = byte.toRadixString(2).substring(1);
        if (bitstring_7_part.length != 7) { throw Exception('look at this, seems leb128 byte is with the wrong-code?'); }
        bitstring = bitstring + bitstring_7_part;
    }
    BigInt valuebigint = BigInt.parse(bitstring, radix: 2);
    return valuebigint;
}