Dishonored
Dishonored

Reputation: 16

Flutter unzip folder is empty (flutter_archive 4.2.0)

In the following code I select a zip file with filePicker that is in the downloads folder of the device, I say that the extraction point will be the same folder but when I select the file and perform the extraction process, everything in the log looks perfect, but when I access the created directory it says that it is empty. I attach the code:

FilePickerResult? result = await FilePicker.platform.pickFiles();

    if (result != null) {
      final zip = File(result.files.single.path.toString());
      final unZip = Directory("/storage/emulated/0/Download");
      print(unZip.path.toString());
      print(zip);
      try{
        ZipFile.extractToDirectory(zipFile: zip, destinationDir: unZip);
      }catch(e){
        print(e);
      }

These are the permissions that I have assigned in my AndroidManifest:

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

Upvotes: 0

Views: 561

Answers (1)

dreambit.io dreambitio
dreambit.io dreambitio

Reputation: 1902

Try using this

final tempDir = await getTemporaryDirectory();
final unZip = Directory('${tempDir.path}/Download');

instead of this

final unZip = Directory("/storage/emulated/0/Download");

Upvotes: 1

Related Questions