mangayomi-mirror/epubx/example/web_ex/web/main.dart
2025-05-04 23:45:46 +02:00

17 lines
628 B
Dart

import 'dart:html';
import 'package:http/http.dart' as http;
import 'package:epubx/epub.dart' as epub;
void main() async {
querySelector('#output').text = 'Your Dart app is running.';
var epubRes = await http.get('alicesAdventuresUnderGround.epub');
if (epubRes.statusCode == 200) {
var book = await epub.EpubReader.openBook(epubRes.bodyBytes);
querySelector('#title').text = book.Title;
querySelector('#author').text = book.Author;
var chapters = await book.getChapters();
querySelector('#nchapters').text = chapters.length.toString();
querySelectorAll('h2').style.visibility = 'visible';
}
}