compressToBase64 static method
Produces ASCII UTF-16 strings representing the original string encoded in Base64 from input
.
Can be decompressed with decompressFromBase64
.
This works by using only 6bits of storage per character. The strings produced are therefore 166% bigger than those produced by compress
.
Implementation
static Future<String?> compressToBase64(String? input) async {
if (input == null) return "";
String res = await _compress(input, 6, (a) => _keyStrBase64[a]);
switch (res.length % 4) {
case 0:
return res;
case 1:
return res + "===";
case 2:
return res + "==";
case 3:
return res + "=";
}
return null;
}