Samuel Aberra
Samuel Aberra

Reputation: 11

CosmosEpub Does Not Restore Last Read Page (Only Restores Chapter)

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.

Expected Behavior

Code Sample

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');
  }
}

Steps to Reproduce

  1. Open a book, read a few pages, then close it.
  2. Reopen the book.
  3. The book opens at the correct chapter, but always from page 1 of that chapter.

Tested On

Is there a way to restore both chapter and page on reopen? Thanks for the great work!

Upvotes: 1

Views: 7

Answers (0)

Related Questions