Compress String to Dart

I have created a webpage with Dart. The user uploads work data in text format. The data capacity will be very large, like a few megabytes. It was up to several kilobytes. When I compress files to ZIP.

I found a way to compress a string using the Javascritp library.

Is there a way to compress a string in Dart?

+3


source to share


1 answer


You can use the archive package from the pub. It supports multiple compression algorithms and container formats. It works in both browser and DartVM without using mirrors.

Once you've got your zip binary data (e.g. via HttpRequest

, see here for how to get a list of contiguous bytes ) you can open and read the zip file using the ZipDecoder

class:



  Archive archive = new ZipDecoder().decodeBytes(bytes);

  for (ArchiveFile file in archive) {
    String filename = file.name;
    List<int> data = file.content;

    // Do something with the data from the file
  }

      

+1


source







All Articles