pre class="language-dart"><code class="language-dart">List&lt;int&gt; convert(Object object) {
  var bytes = &lt;List&lt;int&gt;&gt;[];
  &#47;&#47; The `stringify` function always converts into chunks.
  &#47;&#47; Collect the chunks into the `bytes` list, then combine them afterwards.
  void addChunk(Uint8List chunk, int start, int end) {
    if (start &gt; 0 || end &lt; chunk.length) {
      var length = end - start;
      chunk =
          Uint8List.view(chunk.buffer, chunk.offsetInBytes + start, length