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