Reputation:
I created a Web page with Dart. The user downloads the work data in a text format . The capacity of the data will be very large as several megabytes . It was down to a few kilobytes When I compress the files in ZIP.
I found a way to compress the string by using a library of Javascritp.
Is there a way to compress the string in Dart?
Upvotes: 3
Views: 1315
Reputation: 13570
You can use the archive package from pub. It supports multiple compression algorithms and container formats. It works both in the browser and the DartVM, without using mirrors.
After you received your binary zip data (e.g. via HttpRequest
, see here how to get a continuous byte list) 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
}
Upvotes: 1