EpubBook class
Represents a complete EPUB book with all content loaded into memory.
An EpubBook contains all the data from an EPUB file including metadata, content files, and chapters. This is the result of calling EpubReader.readBook or similar methods that load the entire book into memory.
For memory-efficient lazy loading, use EpubBookRef instead.
Structure
- Metadata: title, author(s)
- Schema: EPUB structure information (OPF, NCX)
- Content: all files (HTML, CSS, images, fonts)
- Chapters: hierarchical chapter structure with full HTML content
- Cover: extracted cover image
Example
final bytes = await File('book.epub').readAsBytes();
final book = await EpubReader.readBook(bytes);
print('Title: ${book.title}');
print('Author: ${book.author}');
print('Chapters: ${book.chapters.length}');
// Access first chapter
if (book.chapters.isNotEmpty) {
final firstChapter = book.chapters[0];
print('Chapter: ${firstChapter.title}');
print('Content: ${firstChapter.htmlContent}');
}
// Access images
book.content?.images?.forEach((name, image) {
print('Image: $name');
});
Constructors
-
EpubBook({String? title, String? author, List<
String?> authors = const <String>[], EpubSchema? schema, EpubContent? content, Image? coverImage, List<EpubChapter> chapters = const <EpubChapter>[]}) -
const
Properties
-
The book's author as a comma-separated string.
For multiple authors, this contains all names joined with commas.
final
-
List of all author names.
Each author is a separate element in the list.
final
-
chapters
→ List<
EpubChapter> -
The hierarchical chapter structure.
Each chapter may contain subchapters, representing the book's navigation structure.
With NCX/spine reconciliation, all content files are guaranteed to be accessible.
final
- content → EpubContent?
-
All content files in the EPUB.
Includes HTML files, CSS stylesheets, images, fonts, and other resources.
final
- coverImage → Image?
-
The book's cover image, if available.
Extracted from the OPF manifest or as a fallback from the first image.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- schema → EpubSchema?
-
The complete EPUB schema information.
Contains OPF package data, navigation (NCX), and other structural information.
final
- title → String?
-
The book's title as specified in the metadata.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
covariant EpubBook other) → bool -
The equality operator.
override