Skip to content

Commit

Permalink
change epub file downloading to a simpler one.
Browse files Browse the repository at this point in the history
  • Loading branch information
FlafyDev committed Aug 11, 2022
1 parent 05cb272 commit 8fabecd
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions lib/widgets/book_downloader_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,13 @@ class _BookDownloaderInterfaceState extends State<BookDownloaderInterface> {
return null;
}

final res = await httpClient.send(Request('GET', uri));
final res = await httpClient.get(uri);

final List<int> bytes = [];

res.stream.listen((value) {
setState(() {
downloadProgress = res.contentLength == null
? null
: ((downloadProgress ?? 0) + value.length / res.contentLength!) / 2;
});
bytes.addAll(value);
})
..onDone(() async {
completer.complete(bytes);
})
..onError((error) {
completer.complete(null);
});
if (res.statusCode != 200) {
return null;
}

return completer.future;
return res.bodyBytes;
}

Future<void> begin() async {
Expand Down

0 comments on commit 8fabecd

Please sign in to comment.