Universal Dockit ποΈ
β οΈ Notice: This plugin is currently under Beta version. APIs, UI, and rendering behavior may change as we continue to improve support for various document types.
A powerful, high-performance Flutter plugin for viewing a wide variety of documents natively on Android and iOS.
Universal Dockit leverages the best open-source native SDKs and built-in OS frameworks to render documents quickly and beautifully, keeping the Flutter layer minimal and efficient.
Absolutely no commercial dependencies, no cloud processing, and 100% on-device rendering.
β¨ Features
- Universal Format Support: Open 15 different document types including PDF, Word, Excel, PowerPoint, EPUB, CBZ, Text, CSV, RTF, and OpenDocument formats.
- Native Performance: Documents are rendered natively using optimized libraries like
PdfiumAndroidon Android andPDFKit/QuickLookon iOS. - Format-Specific Themes: Beautiful, color-coded native headers (e.g., Blue for Word, Green for Excel, Purple for EPUB) provide a cohesive, premium UI out-of-the-box.
- Smart Rendering: Formula evaluation in spreadsheets, native zooming and scrolling for PDFs, and HTML structural extraction for E-Books and Comic Books.
- Fully Offline: Everything is parsed and rendered entirely on the device without cloud APIs or heavy monolithic frameworks.
π Supported Formats & Native Renderers
The plugin intelligently routes each file type to the most appropriate native renderer:
| Format | Extension | Android Engine | iOS Engine |
|---|---|---|---|
.pdf |
PdfiumAndroid (Hardware accelerated) | PDFKit (Built-in) | |
| Word (doc, docx) | .doc, .docx |
All Documents Reader SDK | QuickLook (Built-in) |
| Excel (xls, xlsx) | .xls, .xlsx |
All Documents Reader SDK | CoreXLSX β HTML Table β WebView |
| PowerPoint (ppt, pptx) | .ppt, .pptx |
All Documents Reader SDK | QuickLook (Built-in) |
| EPUB E-Book | .epub |
Native ZIP β spine/HTML extraction β WebView | ZIPFoundation β spine/HTML β WebView |
| CBZ Comic Book | .cbz |
Native ZIP β Image extraction β WebView | ZIPFoundation β Image extraction β WebView |
| Text | .txt |
Native TextView (Monospace, memory-efficient) |
Native UITextView (Monospace) |
| CSV | .csv |
RFC-4180 Parser β HTML Table β WebView | Aligned Plain-text Table β UITextView |
| Rich Text | .rtf |
Native HTML Parser β Html.fromHtml β TextView |
NSAttributedString β UITextView |
| OpenDocument | .odt, .ods, .odp |
In-house ZIP/XML Parser β HTML β WebView | QuickLook (Built-in) |
π Setup & Installation
Requirements:
- Flutter SDK:
>=3.10.0 - Dart SDK:
>=3.0.0 <4.0.0
Add universal_dockit to your pubspec.yaml:
dependencies:
universal_dockit: ^1.0.0
π€ Android Setup
- Minimum SDK: Ensure your
minSdkVersionis at least 24 inandroid/app/build.gradle. - JitPack Repository: Ensure that JitPack is added to your project's
settings.gradleor rootbuild.gradlebecause the document reader SDK is hosted there.
Because the plugin handles the heavy lifting with its own build.gradle.kts, you don't need to add any specific repository exclusions manually in your app module.
π iOS Setup
- Minimum iOS Version: Ensure your iOS deployment target is at least iOS 13.4 in your
ios/Podfile:platform :ios, '13.4' - Install Pods: Run the following from your
iosdirectory:pod install
(Note: The iOS implementation uses pure Swift libraries and built-in Apple frameworks like QuickLook and PDFKit).
π Usage
Using the plugin is incredibly simple. Just provide the absolute file path to the document.
import 'package:flutter/material.dart';
import 'package:universal_dockit/universal_dockit.dart';
// ... inside your widget class
final _universalDockitPlugin = UniversalDockit();
Future<void> openMyDocument(String filePath) async {
try {
// The plugin will automatically infer the document type from the extension.
final success = await _universalDockitPlugin.openDocument(filePath);
if (!success) {
debugPrint("Could not open the document.");
}
} catch (e) {
debugPrint("Error opening document: $e");
}
}
// Alternatively, you can explicitly provide the document type:
// await _universalDockitPlugin.openDocument(filePath, docType: DocType.pdf);
Explicit Document Types
If your file doesn't have an extension, or you want to force a specific renderer, you can pass the DocType enum explicitly:
await _universalDockitPlugin.openDocument(
'/path/to/file_without_extension',
docType: DocType.docx,
);
Supported DocType values: pdf, doc, docx, xls, xlsx, ppt, pptx, epub, cbz, txt, csv, rtf, odt, ods, odp.
Configuring Document Features
By default, the plugin automatically enables all standard viewer features (zooming, searching, page navigation, etc.). You can configure specific features by passing a DocumentFeatures object.
await _universalDockitPlugin.openDocument(
filePath,
features: const DocumentFeatures(
darkMode: true, // Enable native dark mode rendering
zoomInOut: true,
search: true,
// Note: All other features like textSelection, renderImages, etc.,
// are enabled by default. Only specify what you want to change!
),
);
π Architecture Under the Hood
To keep the codebase maintainable and performant, the native code is split using the Strategy Pattern:
- Android:
UniversalDockitPluginhandles dispatching. Office documents (Word, Excel, PPT) are routed to the specializedAll_Document_Reader_Activityfrom the SDK. Other formats useDocumentViewerActivity, which acts as a host and dispatches rendering to specific consolidated implementations ofDocumentRenderer(e.g.,PdfDocumentRenderer,EpubDocumentRenderer). Communication is handled via aRenderCallbacksinterface. - iOS:
UniversalDockitPlugin.swiftroutes requests to dedicatedUIViewControllersubclasses (e.g.,PDFViewerViewController,XLSXViewerViewController,EpubViewerViewController).
π€ Contributing and Feedback
We welcome contributions and feedback! Hereβs how you can help:
π Reporting Bugs
If you find a bug, please open an issue with:
- A clear description of the problem.
- Steps to reproduce the issue.
- The document format (e.g., PDF, DOCX) causing the issue.
- Your Flutter version and the platform (Android/iOS) where the issue occurs.
π‘ Requesting Features
Feature requests are always welcome! If there's a specific document format, UI feature, or performance enhancement you'd like to see:
- Open an issue outlining your feature request.
- Describe the use case and why it would be helpful.
π οΈ Contributing Code
We love pull requests! If you'd like to contribute directly to the code:
- Fork the repository.
- Create a new branch for your feature or bugfix (
git checkout -b feature/my-new-feature). - Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/my-new-feature). - Open a Pull Request.
Please ensure your code follows standard Flutter linting rules.
π License
This project is licensed under the MIT License - see the LICENSE file for details.
Open-source libraries used internally:
- PdfiumAndroid (Apache 2.0)
- All Documents Reader
- CoreXLSX (Apache 2.0)
- ZIPFoundation (MIT)