I want to compress a string in Dart (in the browser). I tried this:
import 'package:archive/archive.dart';
[...]
List<int> stringBytes = UTF8.encode(myString);
List<int> gzipBytes = new GZipEncoder().encode(stringBytes);
String compressedString = UTF8.decode(gzipBytes, allowMalformed: true);
Obviously UTF8.decode
is not intended for this and it doesn't work (file is unreadable).
What is the right way to compress a string in Dart?