tableOfContents method
List<EpubViewChapter>
tableOfContents(
)
Implementation
List<EpubViewChapter> tableOfContents() {
if (_cacheTableOfContents != null) {
return _cacheTableOfContents ?? [];
}
if (_document == null) {
return [];
}
int index = -1;
return _cacheTableOfContents =
_document!.Chapters!.fold<List<EpubViewChapter>>(
[],
(acc, next) {
index += 1;
acc.add(EpubViewChapter(next.Title, _getChapterStartIndex(index)));
for (final subChapter in next.SubChapters!) {
index += 1;
acc.add(EpubViewSubChapter(
subChapter.Title, _getChapterStartIndex(index)));
}
return acc;
},
);
}