decode method

Uint8List decode(
  1. String string
)

Implementation

Uint8List decode(String string) {
  if (string.isEmpty) {
    throw ArgumentError('Non-base$_base character');
  }
  List<int> bytes = [0];
  for (var i = 0; i < string.length; i++) {
    int? value = ALPHABET_MAP[string[i]];
    if (value == null) {
      throw ArgumentError('Non-base$_base character');
    }
    int carry = value;
    for (int j = 0; j < bytes.length; ++j) {
      carry += bytes[j] * _base;
      bytes[j] = carry & 0xff;
      carry >>= 8;
    }
    while (carry > 0) {
      bytes.add(carry & 0xff);
      carry >>= 8;
    }
  }
  // deal with leading zeros
  for (var k = 0; string[k] == _leader && k < string.length - 1; ++k) {
    bytes.add(0);
  }
  return Uint8List.fromList(bytes.reversed.toList());
}