How to compress a string using GZip or similar in Dart?
问题 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? 回答1: The compressed list of bytes is probably not a valid UTF8