sakura_epub 0.1.3
sakura_epub: ^0.1.3 copied to clipboard
A full-featured Flutter EPUB reader package. Render EPUB 2 & 3 books with annotations, search, themes, and programmatic navigation — powered by epub.js.
Changelog #
All notable changes to sakura_epub will be documented in this file.
Format follows Keep a Changelog · versioning follows Semantic Versioning.
sakura_epub is a fork of flutter_epub_viewer by fayis.dev (BSD-3-Clause).
All changes below are relative to the upstreamflutter_epub_viewerbaseline.
0.1.3 — 2026-04-09 #
Fixed #
EpubThemeanalyzer lint — added the missing return type annotation for_decorationToJsonto satisfylints_corestatic analysis.
0.1.2 — 2026-04-08 #
Fixed #
- Missing return type annotations — all methods in
EpubControllerthat lacked explicit return types (void,Future<void>) now declare them, satisfyingtype_annotate_public_apisand related lints in stricter lint rulesets (e.g.lints_core).
0.1.1 — 2026-04-08 #
Fixed #
- Font family picker now changes book text — selecting a font in the reader settings actually
applies that font to the epub content. Root cause:
font-familyCSS was applied via epub.js themes but the font bytes were never loaded inside the epub's isolated iframes, so the browser always fell back to the system default. Fix: addedsetFontFamily()which injects an@font-facedeclaration (with base64-encoded font data) directly into each rendered epub iframe and registers a content hook so newly navigated sections receive the same injection automatically. EpubController.setFontFamily()— new public API to set the reader font at runtime. AcceptsfontFamily, optionalfontBase64(base64-encoded ttf/otf bytes), andfontMimeType.EpubControllerJS calls migrated tocallAsyncJavaScript— allevaluateJavascriptcalls that pass user-controlled strings (CFI, query, color values, etc.) were replaced withcallAsyncJavaScript(functionBody, arguments)to avoid quoting/injection issues with special characters in CFI strings or search queries.- Stale
Completercancellation —getCurrentLocation()andsearch()now cancel any in-flight completer before starting a new request, preventing stale callbacks from resolving future results incorrectly.
Changed #
- All
Color.withOpacity()calls replaced withColor.withValues(alpha:)(Flutter deprecation). - Color component accessors updated:
.alpha/.red/.green/.blue→.a/.r/.g/.b. - Removed redundant imports flagged by the analyzer.
0.1.0 — 2026-04-07 #
This is the first independent release of sakura_epub, forked from flutter_epub_viewer v1.2.8.
Added #
Typography & Appearance
- 16 bundled reader fonts — fonts are embedded in the package so consumers need zero extra setup: New York, Gilroy, Alegreya, Amazon Ember, Atkinson Hyperlegible, Bitter Pro, Bookerly, Droid Sans, EB Garamond, Gentium Book Plus, Halant, IBM Plex Sans, Linux Libertine, Literata, Lora, Ubuntu
EpubThemebackground color propagation — the background color is now correctly extracted frombackgroundDecoration(BoxDecoration.color) and forwarded to epub.jsupdateTheme()as a hex string. The upstream library always passednull, causing a black screen when the EPUB's own CSS set a dark body background.EpubController.updateTheme()background fix — same extraction applied to the runtime theme-switching path so live theme changes also set the epub.js body background correctly.
Stability & Performance
- Base64 EPUB loading — large EPUB files are now base64-encoded in Dart and decoded with
atob()in JavaScript instead of being serialised as a comma-separated byte array ([12,34,56,…]). For a 17 MB file the JS string shrinks from ~51 MB to ~23 MB, eliminating OOM crashes and ANR timeouts on mid-range Android devices. epubView.jsbase64 decoder — the bundled JavaScript detects whetherdatais aString(base64) or anArray(legacy) and decodes accordingly, maintaining backward compatibility.
Package Infrastructure
- Asset path corrected — internal WebView asset reference updated from
packages/flutter_epub_viewer/lib/assets/webpage/html/swipe.htmltopackages/sakura_epub/lib/assets/webpage/html/swipe.html. - Font asset paths corrected — all
fonts:entries inpubspec.yamlupdated from the non-existentassets/fonts/to the reallib/assets/fonts/directory. pubspec.yamlassets section cleaned — removed non-existentassets/fonts/andassets/animations/entries; added correctlib/assets/fonts/entry.
Example App
- Complete rewrite of
example/lib/main.dartwith a modern, immersive reader UI:- Full-screen reader with tap-to-reveal top/bottom bars (animated fade)
- Frosted-glass top bar: chapter list, search, and settings controls
- Frosted-glass bottom bar: slim progress track, prev/next navigation
- Draggable bottom sheet for reading settings (theme swatches + font-size slider)
- Draggable chapter-list bottom sheet with numbered chips
- Dedicated search input sheet and search-results sheet
- Floating selection bar with one-tap highlight and clear actions
- Animated loading screen (pulsing book icon + progress bar, themed to current epub background)
- Full adaptive dark/light color system driven by the active
EpubThemeType
Upstream history (flutter_epub_viewer) #
The following is a condensed history of the upstream library that sakura_epub was forked from. Full details: https://pub.dev/packages/flutter_epub_viewer/changelog
| Version | Highlights |
|---|---|
| 1.2.8 | Fixed getCurrentLocation() |
| 1.2.7 | Added customCss support in EpubTheme |
| 1.2.6 | Fixed dispose issue |
| 1.2.5 | onTouchDown/onTouchUp; selectAnnotationRange; XPath/XPointer navigation |
| 1.2.4 | onSelection with WebView-relative coords; onSelectionChanging; onDeselection; clearSelectionOnPageChange; selection block during navigation |
| 1.2.3 | iOS chapter parsing improvements |
| 1.2.2 | Book metadata (getMetadata()) |
| 1.2.1 | Theme change at runtime; first/last page navigation; font-size relocation fix |
| 1.2.0 | EpubTheme with background and foreground color |
| 1.1.6 | Remove-highlight fix |
| 1.1.5 | LTR/RTL fixes; sub-chapter parsing; onRelocated fix on Android |
| 1.1.4 | Size-fit fixes |
| 1.1.3 | Reading progress |
| 1.1.2 | Annotation click handler |
| 1.1.1 | Book reload fix |
| 1.1.0 | Local file & asset loading; underline annotation; text extraction |
| 1.0.1 | Fixed blank screen |
| 1.0.0 | Initial release — highlights, search, chapters, text selection, CFI navigation |