1

I am trying to make an installer, where I download a zip file from a source and extract it to a specific path.
The only package that works with windows applications is the archive package, please note that only archive_io version works with applications, and the archive version only works for web apps(if you intend to read the documentation).
My problem is that I am trying to update the UI with a percentage of the extraction progress, however nothing I tried seems to work, setting the return type of my function to a stream will make the function in its entirety stops working, setting it to a future, will freeze the UI until the whole function completes. Also, I am trying to make it work for big files, and using the readAsBytes() function will break my application without throwing any exceptions, even if the file is as small as 200MB.

_extractFileClean() async {
    // path to compressed file
    String path = "C:\\Users\\myUser\\Desktop\\compressedFile.zip";

    // getting file & directory
    File file = File(path);
    Directory directory = file.parent;

    final inputStream = InputFileStream(path);
    var archive = ZipDecoder().decodeBuffer(inputStream);

    // extract the files to parent of the compressed file itself
    extractArchiveToDisk(archive, directory.path);
  }
  • cannot you use tar.gz files instead? with them you could use `gzip` codec to uncompress your data – pskink Mar 08 '23 at 08:08
  • @pskink, Thanks for your response, I am able to extract the files with the code I provided, however, my real problem is the UI freezing and not being able to update it with extraction progress. – Shadi Aslan Mar 08 '23 at 08:10
  • this is because you are using not steamed solution - `archive` package - instead you need a streamed solution like `tar` package, for example check this answer https://stackoverflow.com/questions/68739325/how-to-deploy-initial-data-to-flutter-app#68755804, the second solution after **EDIT** – pskink Mar 08 '23 at 08:17
  • @pskink It works, thank you so much man, anyway u could add this as an answer please so I mark it as resolved? Also, any idea how I go on about update the UI with the extraction progress? – Shadi Aslan Mar 08 '23 at 09:21
  • call `setState` inside the loop – pskink Mar 08 '23 at 10:45

1 Answers1

0

Switched from zip files to tar files, using the tar package it's working fine.