🚀 flutter_web_file_saver

pub package pub points likes License: MIT

The Most Comprehensive Flutter Web File Saver

📸 Screenshots

Main demo interface showing all 6 categories Advanced features: ZIP, Canvas, Batch operations
Native browser save dialog

25+ Methods • ZIP Archives • Canvas Export • Batch Operations

FeaturesInstallationUsageAPI Reference


🌟 Why This Package?

✅ What We Offer

  • 25+ specialized methods
  • ZIP archive creation
  • Canvas/widget export
  • Batch operations
  • Video & audio support
  • 3 lightweight dependencies
  • 100% web-optimized
  • Production-ready

❌ What Others Miss

  • Only 4-5 generic methods
  • No ZIP support
  • No canvas export
  • No batch operations
  • Limited media support
  • 7+ heavy dependencies
  • Multi-platform bloat
  • Complex APIs

✨ Features at a Glance

🗜️

ZIP Archives

Bundle multiple files into
a single download

📸

Canvas Export

One-line screenshot
of any widget

🔄

Batch Operations

Save multiple files
with progress

🎥

Video & Audio

Full media file
support

📄

All Formats

PDF, CSV, JSON
XML, HTML, MD

Simple API

Intuitive methods
zero config


📦 Installation

Add to your pubspec.yaml:

dependencies:
  flutter_web_file_saver: ^2.0.0

Then run:

flutter pub get

🚀 Quick Start

import 'package:flutter_web_file_saver/flutter_web_file_saver.dart';

// Simple text save
await FlutterWebFileSaver.saveText(
  content: 'Hello, World!',
  filename: 'hello.txt',
);

// Save as ZIP
await FlutterWebFileSaver.saveAsZip(
  files: {
    'doc.pdf': pdfBytes,
    'image.png': imageBytes,
  },
  zipFilename: 'bundle.zip',
);

// Export canvas
await FlutterWebFileSaver.saveFromCanvas(
  key: _chartKey,
  filename: 'chart.png',
);

// Batch save
await FlutterWebFileSaver.saveMultipleFiles(
  files: fileList,
  onProgress: (current, total) => print('$current/$total'),
);

📊 Complete Method List

Category Methods Description
Text Files saveText() Plain text files
saveJson() JSON with pretty-print
saveCsv() CSV with custom delimiter
saveHtml() HTML pages
saveMarkdown() Markdown documents
saveXml() XML data
saveAsBase64() Base64 encoded
Images saveImageUrl() From URLs/data URLs
saveFromCanvas() Export widget/canvas
Video saveVideoUrl() From URLs
saveVideoBlob() From MediaRecorder
saveVideo() From bytes
Audio saveAudioUrl() From URLs
saveAudioBlob() From MediaRecorder
saveAudio() From bytes
Archives saveAsZip() Multiple files → ZIP
Batch saveMultipleFiles() Sequential saves
Utilities saveFile() Generic binary
saveWithAutoDetect() Auto MIME detection
generateDataUrl() Create data URLs
generateBlobUrl() Create blob URLs
saveTableAsHtml() HTML table generator
saveAuto() Auto format detection

Total: 25+ methods!


🎯 Use Cases

📊 Analytics Dashboards

  • Export charts as images
  • Save reports as PDFs
  • Download data as CSV/JSON
  • Batch export multiple reports

🛒 E-Commerce

  • Generate invoices (HTML/PDF)
  • Export order receipts
  • Bulk invoice generation
  • Customer data exports

🎨 Design Tools

  • Canvas/widget export
  • Asset bundling (ZIP)
  • Screenshot capture
  • Project packages

📚 Education

  • Assignment bundles
  • Certificate generation
  • Resource packages
  • Course materials

💡 Examples

Save as ZIP Archive

final files = {
  'document.pdf': pdfBytes,
  'image.png': imageBytes,
  'data.json': jsonBytes,
  'report.csv': csvBytes,
};

final result = await FlutterWebFileSaver.saveAsZip(
  files: files,
  zipFilename: 'project_bundle.zip',
);

if (result.success) {
  print('ZIP created successfully!');
}

Export Canvas/Screenshot

// Wrap your widget with RepaintBoundary
final GlobalKey _canvasKey = GlobalKey();

RepaintBoundary(
  key: _canvasKey,
  child: MyChartWidget(),
)

// Export as image
final result = await FlutterWebFileSaver.saveFromCanvas(
  key: _canvasKey,
  filename: 'chart_screenshot.png',
  pixelRatio: 3.0, // Higher = better quality
);

Batch Save Multiple Files

final files = [
  FileToSave(bytes: pdf1, filename: 'report1.pdf'),
  FileToSave(bytes: pdf2, filename: 'report2.pdf'),
  FileToSave(bytes: image1, filename: 'chart.png'),
];

final results = await FlutterWebFileSaver.saveMultipleFiles(
  files: files,
  onProgress: (current, total) {
    print('Saving $current of $total');
  },
);

// Check results
final allSuccess = results.every((r) => r.success);

Save Video/Audio

// From MediaRecorder blob
final result = await FlutterWebFileSaver.saveVideoBlob(
  videoBlob: recordedBlob,
  filename: 'my_recording.webm',
);

// From URL
await FlutterWebFileSaver.saveAudioUrl(
  audioUrl: audioUrl,
  filename: 'podcast.mp3',
  mimeType: MimeTypes.mp3,
);

📖 Documentation


🆚 Comparison

Feature This Package Other Solutions
Available Methods ✅ 25+ ⚠️ Typically 5–10
ZIP File Support ✅ Yes ❌ Not commonly supported
Canvas Export ✅ Yes ❌ Not commonly supported
Batch Operations ✅ Yes ⚠️ Limited or unavailable
Video / Audio Handling ✅ Yes ⚠️ Limited
Dependencies ✅ 3 ⚠️ Typically 5+
Web Optimization ✅ Designed for web ⚠️ Varies by implementation
Bundle Size Impact ✅ Small ⚠️ Medium

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


💖 Support

If you find this package helpful, please:


Made with ❤️ for the Flutter community

Report BugRequest FeatureDocumentation

Libraries

flutter_web_file_saver
A simple, powerful Flutter plugin for downloading and saving files in web applications.
flutter_web_file_saver_web