flutter_epub_viewer 2.0.0
flutter_epub_viewer: ^2.0.0 copied to clipboard
A Flutter package for viewing Epub documents developed by combining the power of Epubjs and flutter_inappwebview
2.0.0 #
Adds Flutter Web and macOS support and a substantial architecture cleanup for performance, stability and maintainability.
✨ New #
- Flutter Web support. On the web the viewer runs epub.js inside a native
<iframe>(viaHtmlElementView) and bridges to it withdart:js_interopinstead of a webview plugin — allEpubController/EpubViewerAPIs and callbacks work the same as on mobile. - macOS support. macOS reuses the existing
flutter_inappwebview(WKWebView) rendering path as iOS/Android, so all APIs and callbacks behave the same. Requires macOS 10.13+ (perflutter_inappwebview). EpubSource.fromData(Uint8List)— load an EPUB from in-memory bytes (recommended on the web, wherefromFileis unavailable andfromUrlis subject to CORS).EpubContextMenu/EpubContextMenuItem— package-owned selection context menu types (mobile), replacing the re-exportedflutter_inappwebviewtypes.EpubController.requestTimeout— configurable timeout for request/response calls (default 20s).
🩹 Stability #
- Request/response calls (
getCurrentLocation,search,extractText,getRectFromCfi,extractCurrentPageText,getMetadata,getChapters) now return their values directly and time out instead of hanging forever if the JS side fails to reply. The previous shared-Completerdesign could hang or drop concurrent calls. getRectFromCfinow works (it previously called a JS function that did not exist and never completed).- Annotation taps now reliably fire
onAnnotationClicked(themarkClickedevent was never emitted to Dart before).
⚡ Performance #
- Text-selection polling is disabled on web/desktop (browsers fire
selectionchangereliably), removing perpetual background 200ms/2000ms timers. Mobile keeps the iOS/iPad polling fallback. - Mobile transfers the EPUB bytes to JS as base64 instead of a decimal array literal (a 4 MB book is ~5.5 MB of source instead of ~16 MB).
🧹 Maintainability #
EpubControllerno longer depends onflutter_inappwebviewdirectly; all platform communication goes through anEpubWebViewControllerbridge.loadBooknow takes an options object instead of 16 positional arguments.- CFI/XPath conversion helpers were extracted from
epubView.jsintoepub_cfi_utils.js(main glue file reduced by ~700 lines). - Added a unit-test suite (controller RPC/parsing/timeout + model round-trips).
⚠️ Breaking changes #
- The package no longer re-exports
ContextMenu,ContextMenuSettings,ContextMenuItemfromflutter_inappwebview. UseEpubContextMenuandEpubContextMenuItem:// before selectionContextMenu: ContextMenu( menuItems: [ContextMenuItem(id: 1, title: 'Highlight', action: ...)], settings: ContextMenuSettings(hideDefaultSystemContextMenuItems: true), ), // after selectionContextMenu: EpubContextMenu( hideDefaultSystemItems: true, items: [EpubContextMenuItem(id: 1, title: 'Highlight', action: ...)], ), EpubController.webViewControlleris nowEpubWebViewController?(wasInAppWebViewController?). The removed internal memberssearchResultCompleter,currentLocationCompleter,cfiRectCompleterandcompletePageText()were implementation details and are gone.- Request methods now throw
TimeoutException(fromdart:async) on timeout.
1.2.8 #
- Fixed
getCurrentLocationfunction
1.2.7 #
- Added
customCsssupport inEpubThemefor granular styling
1.2.5 #
1.2.4 #
- Initial progress fixes
- Relocation on font change fixes
- background decoration fixes
- Added onSelection callback with WebView-relative coordinates for custom selection UI
- Added onSelectionChanging callback for detecting selection handle dragging
- Added onDeselection callback for selection cleared events
- Added clearSelectionOnPageChange property to control selection behavior on navigation
- Fixed suppressNativeContextMenu to properly hide native context menu
- Fixed text selection coordinate mapping for accurate positioning
1.2.3 #
- iOS chapter parsing fixes
1.2.2 #
- Added book metadata
1.2.1 #
- Fixed book loading issues
- Fixed font size adjust issues
- Added change theme function
- Added navigation to first and last pages
1.2.0 #
- Added Epub Theme with background and foreground color
1.1.6 #
- Remove Highlight fix
1.1.5 #
- LTR -RTL fixes
- Sub chapter parsing fixes
- Fixed
onRelocatedcallback on Android - Changed Default display settings
1.1.4 #
- Size fit fixes
1.1.3 #
- Added reading progress
1.1.2 #
- Added Annotation click handler
1.1.1 #
- Fixed book reloading issues
1.1.0 #
- Added Local file and asset support
- Added underline annotation
- Added text content extraction
1.0.2 #
- Document changes
1.0.1 #
- Fixed blank screen
1.0.0 #
- Highlight text
- Search in Epub
- List chapters
- Text selection
- Highly customizable UI
- Resume reading using cfi
- Custom context menus for selection