universal_file_viewer 0.0.5
universal_file_viewer: ^0.0.5 copied to clipboard
A Flutter package to preview images, videos, PDFs, Word, Excel, CSV, PPT, and more.
UniversalFileViewer - A Flutter package to preview various file types, including images, videos, PDFs, Word, Excel, CSV, and PowerPoint files on Android and iOS.
Features✅ Image preview (JPG, PNG, GIF, BMP, TIFF)<br />
✅ Video playback (MP4, AVI, MOV, MKV)<br />
✅ PDF viewer<br />
✅ Word documents (.doc, .docx)<br />
✅ Excel files (.xls, .xlsx)<br />
✅ CSV file preview<br />
✅ PowerPoint files (.ppt, .pptx)<br />
✅ Text files (.txt, .md)<br />
✅ Fallback to external app if unsupported<br />
##Installation
Add this package to your pubspec.yaml:
dependencies:
universal_file_viewer: latest_versionThen,
run: flutter pub get
Usage
Import the packageimport 'package:universal_file_viewer/universal_file_viewer.dart';
Basic UsageUniversalFileViewer(filePath: '/path/to/your/file');
Example
import 'package:flutter/material.dart';
import 'package:universal_file_viewer/universal_file_viewer.dart';
void main() { runApp(MyApp()); }
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Universal File Viewer')),
body: Center(
child: UniversalFileViewer(filePath: '/storage/emulated/0/Download/sample.pdf'),
),
),
);
}
}
File Type Detection
Internally, the package determines the file type based on its extension:
FileType detectFileType(String path);
Supported File FormatsImages: .jpg, .jpeg, .png, .gif, .bmp, .tiff
Videos: .mp4, .avi, .mov, .mkv
Documents: .pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .csv, .txt, .md
DependenciesThis package leverages:
file_picker for file selection
open_filex for opening unsupported files in external apps
video_player for video playback
syncfusion_flutter_pdfviewer for PDF preview
flutter_office_viewer for Word, Excel, and PowerPoint files
##Future Enhancements
✅ More file format support
✅ Web support
✅ Better UI customization
✅ Encrypted file handling
LicenseThis project is licensed under the MIT License - see the LICENSE file for details. ContributingContributions are welcome! Feel free to submit issues and pull requests. ⭐ If you like this package, consider giving it a star on Github 🚀