open method
Implementation
Future<void> open({String? path, String? url, Uint8List? bytes, String? asset, Object? blob, Map<String, String>? headers}) async {
emit(value.copyWith(state: UDocState.opening, isBusy: true, clearError: true));
try {
final UEpubBook book = await UEpubBook.open(path: path, url: url, bytes: bytes, asset: asset, blob: blob, headers: headers);
_book = book;
_index = await UDocTextIndex.open(book.fingerprint);
outline = book.navigation;
await UDocProgressStore.instance.load();
final UDocProgress? progress = UDocProgressStore.instance.get(book.fingerprint);
emit(
value.copyWith(
state: UDocState.ready,
kind: UDocKind.epub,
pageCount: book.chapterCount,
metadata: book.metadata,
settings: settings.copyWith(direction: book.direction, scrollMode: UDocScrollMode.verticalContinuous),
pageIndex: progress != null && progress.pageIndex < book.chapterCount ? progress.pageIndex : 0,
isBusy: false,
loadedPercent: 1,
clearError: true,
),
);
await _loadHighlights();
} on UDocError catch (error) {
failWith(error);
} on Object catch (error) {
failWith(UDocError(code: UDocErrorCode.corrupt, message: "Could not open the book", detail: "$error"));
}
}