All Projects

Archive Reader

Cross-platform MHTML Reader and Manager

Role
Sole Developer (Architecture, Design, and Development)
Client
Personal Project / Public Distribution
Duration
2026-07-15 — 2026-08-20
Year
2026
Team
1 persona
MobileDesktopUtilities
FlutterDartRiverpodDrift (SQLite)flutter_inappwebviewShelfpackage:archivepackage:httppackage:mimefile_selector
Archive Reader

Problem

What needed to be solved?

Managing MHTML files is complex and unintuitive across mobile and desktop platforms, especially when handling large file sizes and datasets.

Solution

How was it solved?

Developed a cross-platform application that simplifies MHTML reading, management, and creation, with a strong focus on performance, reliability, and user experience.

Features

What it does

  • Multi-library system with folder history and persistent metadata
  • Custom multipart MIME parser compatible with real-world MHTML files across browsers
  • Robust encoding detection (UTF-8, Windows-1252, ISO-8859-1) with charset sniffing from HTML
  • Dual rendering strategy: local HTTP server on Android/iOS and file:// access on Windows
  • Custom scrollbar with proportional positioning based on actual content length
  • MHTML creation from image folders, ZIP files, or web URLs
  • Full web page capture (HTML, images, styles) via headless WebView
  • Dedicated Isolates for file generation with atomic writes to avoid UI blocking
  • Stable handling of files larger than 130MB without memory leaks

Responsibilities

My role in the project

  • Designed the complete application architecture
  • Developed the app end-to-end in Flutter (UI, business logic, persistence)
  • Designed and implemented a custom MIME/MHTML parser
  • Resolved low-level issues (encoding handling, memory management, platform-specific WebView behavior)
  • Performed manual testing on Android and Windows

Technical Challenges

What wasn’t trivial

MHTML compatibility

Achieved cross-compatibility between generated MHTML files and external readers (Chrome, Edge, other apps) by handling reference schemes (Content-Location vs cid:) and CRLF encoding

Memory optimization

Prevented UI blocking and memory leaks when processing files larger than 130MB by offloading heavy work to Isolates and streaming resources incrementally instead of loading them entirely into memory

Android Media Scanner

Diagnosed and mitigated interference from Android’s media scanner when writing files to public storage

WebView vs Flutter gestures

Resolved conflicts between native WebView gestures (e.g., text selection) and Flutter’s GestureDetector

CORS limitations

Worked around CORS restrictions when capturing external web resources without relying on a backend server

Results

What was achieved

  • Delivered a functional application on Android and Windows with feature parity across platforms
  • Generated MHTML files fully compatible with desktop browsers and third-party readers
  • Enabled stable management of large file libraries without degrading UI performance
  • file_selector.getSaveLocation is not supported on Android/iOS; getDirectoryPath is the practical cross-platform alternative
  • Writing large files to a private temporary directory before moving them prevents corruption caused by external processes (media scanners, antivirus)
  • Native WebView events lack consistent behavior across platforms; a JS↔Dart messaging bridge is more reliable than platform-specific callbacks
  • Critically validate technical suggestions from external sources (including AI) before implementation, especially when internally inconsistent
  • Prefer DOM-based HTML manipulation over string replacement for robustness against real-world markup variability