Giter Club home page Giter Club logo

flutter_archive's Introduction

flutter_archive

Create and extract ZIP archive files. Uses Android/iOS/macOS platform APIs for high performance and optimal memory usage.

Features

  • Supports Android (API level 16+), iOS 9+ and macOS 10.11+.
  • Modern plugin implementation based on Kotlin (Android) and Swift (iOS/macOS).
  • Uses background processing to keep UI responsive.
  • Zip all files in a directory (optionally recursively).
  • Zip a given list of files.
  • Unzip an archive file to a given directory.
  • Progress reporting while extracting an archive. Get details of zip entries being extracted and allow skip extracting a zip entry.

Examples

Create a zip file from a directory

  final dataDir = Directory("data_dir_path");
  try {
    final zipFile = File("zip_file_path");
    ZipFile.createFromDirectory(
        sourceDir: dataDir, zipFile: zipFile, recurseSubDirs: true);
  } catch (e) {
    print(e);
  }

Create a zip file from a given list of files.

  final sourceDir = Directory("source_dir");
  final files = [
    File(sourceDir.path + "file1"),
    File(sourceDir.path + "file2")
  ];
  final zipFile = File("zip_file_path");
  try {
    ZipFile.createFromFiles(
        sourceDir: sourceDir, files: files, zipFile: zipFile);
  } catch (e) {
    print(e);
  }

Extract a ZIP archive

  final zipFile = File("zip_file_path");
  final destinationDir = Directory("destination_dir_path");
  try {
    ZipFile.extractToDirectory(zipFile: zipFile, destinationDir: destinationDir);
  } catch (e) {
    print(e);
  }

Get progress info while extracting a zip archive.

  final zipFile = File("zip_file_path");
  final destinationDir = Directory("destination_dir_path");
  try {
    await ZipFile.extractToDirectory(
        zipFile: zipFile,
        destinationDir: destinationDir,
        onExtracting: (zipEntry, progress) {
          print('progress: ${progress.toStringAsFixed(1)}%');
          print('name: ${zipEntry.name}');
          print('isDirectory: ${zipEntry.isDirectory}');
          print(
              'modificationDate: ${zipEntry.modificationDate.toLocal().toIso8601String()}');
          print('uncompressedSize: ${zipEntry.uncompressedSize}');
          print('compressedSize: ${zipEntry.compressedSize}');
          print('compressionMethod: ${zipEntry.compressionMethod}');
          print('crc: ${zipEntry.crc}');
          return ExtractOperation.extract;
        });
  } catch (e) {
    print(e);
  }

flutter_archive's People

Contributors

kinex avatar pin73 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.