chapter method

Future<UEpubChapter> chapter(
  1. int index
)

Implementation

Future<UEpubChapter> chapter(int index) async {
  final UEpubChapter? cached = _chapters[index];
  if (cached != null) return cached;
  final UEpubBook? book = _book;
  if (book == null) return UEpubChapter(spineIndex: index, href: "", blocks: const <UEpubBlock>[], title: "", text: "");
  final UEpubChapter chapter = await book.chapter(index);
  if (_chapters.length > 12) _chapters.clear();
  _chapters[index] = chapter;
  unawaited(_index?.writePage(index, chapter.text) ?? Future<void>.value());
  return chapter;
}