搜尋套件、儲存庫與 APP 分類

cosmos_epub 封面
套件詳情v1.0.1

cosmos_epub

功能豐富的 Flutter EPUB 閱讀器套件,支援頁面翻轉動畫、文字強調、連字處理、無限嵌套章節、圖像支援、從右到左語言、可自訂主題與字型。

AndroidiOS
近 30 天下載
412
喜歡數
46
Pub 分數
70

安裝套件

flutter pub add cosmos_epub

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Cosmos EPUB 是一個功能豐富的 Flutter 套件,用於閱讀 EPUB 檔案,支援流暢的頁面翻轉動畫、文字強調、連字處理,以及無限嵌套章節。它能處理圖片、從右到左的語言,並提供可自訂的主題與字型。非常適合建構具備進階格式化與可及性功能的沉浸式閱讀應用。

適用情境

  • 閱讀EPUB格式的電子書
  • 構建電子閱讀器應用程式
  • 支援多語言和從右到左的文字
  • 建立互動式教育內容
  • 啟用文字強調和註解

主要特色

  • 頁面翻轉動畫
  • 文字強調與連字
  • 無限嵌套的章節結構
  • 圖像和 RTL 語言支援
  • 可自訂的主題和字型

適合對象

  • 電子書閱讀器
  • 教育類應用
  • 多語言內容平台
  • 面向可存取性的應用程式
  • 可自定的閱讀體驗

使用建議

  • 需要小心處理大型 EPUB 檔案
  • 可能需要針對低階設備進行優化
  • 僅限 EPUB 格式
  • 主題自定義需要UI知識
  • 依賴外部 GitHub 倉庫以取得更新

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

CosmosEpub 💫

A feature-rich EPUB reader package for Flutter with page flip animations, text highlighting, hyphenation, infinite nested chapters, image support, RTL languages, customizable themes and fonts.

Showcase

banner

Features

  • Text Highlighting — select text, pick a color (6 options), highlights persist across sessions. Re-highlight to change color. Copy & Select All support.
  • Hyphenation — syllable-aware word breaking for better justified text. Visible "-" at line breaks. Respects Uzbek digraphs (ch, sh, g', o').
  • Infinite Nested Chapters — recursive TOC with unlimited depth. Section title pages auto-generated.
  • Image Support — EPUB images rendered inline (PNG, JPEG, GIF, SVG, WebP).
  • Page Flip Animation — realistic 3D page curl effect with swipe gestures.
  • 5 Themes — Grey, Purple, White, Black, Pink.
  • 14 Fonts — Alegreya, Amazon Ember, Bookerly, EB Garamond, Lora, Ubuntu, and more.
  • RTL Support — Arabic, Persian, Hebrew, Urdu, and other RTL languages with auto-detection.
  • Reading Progress — chapter and page position saved per book.
  • Brightness Control — in-reader brightness slider.
  • Multiple Sources — open EPUB from assets, local file, URL, or raw bytes.
  • Robust Parsing — 3-tier chapter resolution (NCX NavMap → epubx Chapters → Spine order). Handles malformed EPUBs.

Getting Started

Add the dependency:

dependencies:
  cosmos_epub: ^1.0.0
flutter pub get

Usage

Initialize

Call initialize() once before using any other method (preferably in main.dart):

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await CosmosEpub.initialize();
  runApp(MyApp());
}
Open a Book
// From assets
await CosmosEpub.openAssetBook(
  assetPath: 'assets/book.epub',
  context: context,
  bookId: 'my_book_1',
  accentColor: Colors.indigoAccent,
  onPageFlip: (currentPage, totalPages) {
    print('Page $currentPage of $totalPages');
  },
  onLastPage: (lastPageIndex) {
    print('Reached last page');
  },
);

// From local file
await CosmosEpub.openLocalBook(
  localPath: '/path/to/book.epub',
  context: context,
  bookId: 'my_book_2',
);

// From URL
await CosmosEpub.openURLBook(
  urlPath: 'https://example.com/book.epub',
  context: context,
  bookId: 'my_book_3',
);

// From bytes
await CosmosEpub.openFileBook(
  bytes: myUint8List,
  context: context,
  bookId: 'my_book_4',
);
Progress Management
// Get current progress
BookProgressModel progress = CosmosEpub.getBookProgress('my_book_1');
print('Chapter: ${progress.currentChapterIndex}');
print('Page: ${progress.currentPageIndex}');

// Set progress manually
await CosmosEpub.setCurrentChapterIndex('my_book_1', 5);
await CosmosEpub.setCurrentPageIndex('my_book_1', 3);

// Delete progress
await CosmosEpub.deleteBookProgress('my_book_1');
await CosmosEpub.deleteAllBooksProgress();
Highlight Management
// Get all highlights for a book
List<HighlightModel> highlights = CosmosEpub.getBookHighlights('my_book_1');

// Remove a specific highlight
CosmosEpub.removeHighlight(highlights.first.id);

// Remove all highlights for a book
CosmosEpub.removeAllHighlights('my_book_1');
Clear Theme Cache
await CosmosEpub.clearThemeCache();

Parameters

Parameter Type Default Description
assetPath / localPath / urlPath / bytes String / Uint8List required EPUB source
context BuildContext required Build context for navigation
bookId String required Unique ID for progress tracking
accentColor Color Colors.indigoAccent Primary accent color
onPageFlip Function(int, int)? null Called on page change
onLastPage Function(int)? null Called on last page
chapterListTitle String 'Table of Contents' TOC screen title
shouldOpenDrawer bool false Open TOC on start
starterChapter int -1 Start at specific chapter

RTL Language Support 🌍

Automatic detection and support for Right-to-Left languages:

  • Arabic (العربية), Persian (فارسی), Hebrew (עברית), Urdu (اردو)
  • Pashto (پښتو), Sindhi (سنڌي), Kurdish (کوردی), Dhivehi (ދިވެހި), Yiddish (ייִדיש)

No configuration needed — just open the EPUB and the library handles direction, alignment, and navigation automatically.

Notes

  • Each book must have a unique bookId. Using the same ID for different books will cause progress conflicts.
  • Highlights are stored locally via GetStorage and persist across app restarts.
  • The package uses isar_community for progress persistence (Android/iOS/Desktop only, no web support).

License

BSD-3

Contact

Feel free to open an issue or reach out: https://allmylinks.com/mamasodikov

所屬分類

依賴

依賴清單 12 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。