compressToUint8Array static method

Future<Uint8List> compressToUint8Array(
  1. String uncompressed
)

Produces an uint8Array.

Can be decompressed with decompressFromUint8Array

Implementation

static Future<Uint8List> compressToUint8Array(String uncompressed) async {
  String compressed = await compress(uncompressed);
  return Future<Uint8List>(() {
    Uint8List buf = Uint8List(compressed.length * 2);
    for (var i = 0, totalLen = compressed.length; i < totalLen; i++) {
      int currentValue = compressed.codeUnitAt(i);
      buf[i * 2] = currentValue >> 8;
      buf[i * 2 + 1] = currentValue % 256;
    }
    return buf;
  });
}