---
## **UnZipX Example App 🚀**
**Pub Version:** [](https://pub.dev/packages/unzipx)
**License:** MIT
**Platform:** Android | iOS | Windows | macOS | Linux
The **UnZipX Example App** demonstrates how to easily extract ZIP files from assets and save them to the app's support directory. With just **one line of code**, you can load and extract ZIP files in your Flutter app! 🗂✨
---
✅ Extract ZIP from Assets – No need to manually copy files.
✅ Automatic File Saving – Extracted files are stored in the support directory.
✅ Works in void main() – Easy to initialize before running the app.
✅ Cross-Platform Support – Works on Android, iOS, Windows, macOS, and Linux.
✅ Simple & Lightweight – Uses archive and path_provider with minimal dependencies.
Add UnZipX to your pubspec.yaml:
dependencies:
unzipx: ^1.0.0Run the following command:
flutter pub getimport 'package:unzipx/unzipx.dart';Modify your main.dart to extract a ZIP file on app startup:
import 'package:flutter/material.dart';
import 'package:unzipx/unzipx.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
try {
String extractedPath = await UnZipX.init('assets/sample.zip');
print("Files extracted to: $extractedPath");
} catch (e) {
print("Extraction failed: $e");
}
runApp(UnZipXExampleApp());
}
class UnZipXExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('UnZipX Example')),
body: Center(child: Text('Files Extracted Successfully!')),
),
);
}
}Want to extract a ZIP later in the app lifecycle? Use this function:
void extractFiles() async {
try {
String extractedPath = await UnZipX.init('assets/data.zip');
print("Extracted to: $extractedPath");
} catch (e) {
print("Extraction failed: $e");
}
}1️⃣ Loads a ZIP file from assets/
2️⃣ Extracts all files into the app support directory
3️⃣ Returns the extracted folder path
If assets/sample.zip contains:
sample.zip
├── config.json
├── images/
│ ├── image1.png
│ ├── image2.png
├── data.txt
After extraction, the files will be saved in:
/data/user/0/com.example.app/files/ (Android example path)
├── config.json
├── images/
│ ├── image1.png
│ ├── image2.png
├── data.txt
Make sure you declare the ZIP file in pubspec.yaml:
flutter:
assets:
- assets/sample.zipExtract files before the app UI loads:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await UnZipX.init('assets/sample.zip');
runApp(MyApp());
}Extract files on demand with a button:
ElevatedButton(
onPressed: () async {
await UnZipX.init('assets/docs.zip');
},
child: Text("Extract ZIP"),
);| Issue | Solution |
|---|---|
| FileNotFoundException | Ensure the ZIP file is added in pubspec.yaml. |
| Permission Denied | On Android, check storage permissions in AndroidManifest.xml. |
| Slow Extraction | Use smaller ZIP files or reduce the number of files inside. |
📖 Flutter Documentation: flutter.dev
📦 UnZipX on Pub.dev: pub.dev/packages/unzipx
Chinmay Nagar – Flutter Developer & Tech Enthusiast
🔗 Portfolio: chinmaynagar-dev.web.app
💼 LinkedIn: chinmay-nagar-55786424b
📧 Email: nagar.chinmay.7@gmail.com
Now your Flutter app can extract ZIP files effortlessly using UnZipX! 🚀
Drop a ⭐ if you like this package! ❤️