Reputation: 11
I am developing a personal book store app and need a reliable EPUB reader. After testing multiple options, I found CosmosEpub to be the best solution for my needs. However, I encountered an issue where CosmosEpub correctly restores the last read chapter, but it does not restore the exact page within that chapter when reopening a book. Instead, it always starts at the first page of the chapter.
Future<void> _openEpubReader() async {
try {
print('Fetching book progress...');
BookProgressModel? bookProgress = await CosmosEpub.getBookProgress(widget.bookTitle);
int startChapterIndex = bookProgress?.currentChapterIndex ?? 0;
int startPageIndex = bookProgress?.currentPageIndex ?? 0;
await CosmosEpub.setCurrentPageIndex(widget.bookTitle, startPageIndex);
await CosmosEpub.setCurrentChapterIndex(widget.bookTitle, startChapterIndex);
print('Opening local EPUB book...');
await CosmosEpub.openLocalBook(
localPath: widget.filePath,
context: context,
bookId: widget.bookTitle,
starterChapter: startChapterIndex,
onPageFlip: (int currentPage, int totalPages) {
CosmosEpub.setCurrentPageIndex(widget.bookTitle, currentPage);
},
);
} catch (e) {
print('Error opening EPUB: $e');
}
}
Is there a way to restore both chapter and page on reopen? Thanks for the great work!
Upvotes: 1
Views: 7