orthros / dart-epub

Epub Reader and Writer for Dart
MIT License
218 stars 226 forks source link

Trouble with loading cover images. #79

Open gohanko opened 4 years ago

gohanko commented 4 years ago

I tried loading the cover image as per flutter app example, and the library seems to have trouble finding the cover image of the epub file even though it exists (confirmed via other apps and me looking at its meta data).

Here is the code :

Widget buildDocumentItem(epub.EpubBookRef book) {
    return Card(
        child: InkWell(
            splashColor: Colors.black.withAlpha(30),
            onTap: () {

            },
            child: Column(
                children: <Widget>[
                    FutureBuilder<epub.Image>(
                        future: book.readCover(),
                        builder: (context, snapshot) {
                            if (snapshot.hasData) {
                                return Image.memory(image.encodeJpg(snapshot.data));
                            } else if (snapshot.hasError) {
                                return Text("${snapshot.error}");
                            }

                            return Container();
                        }
                    ),
                    Text(book.Title),
                    Text(book.Author),
                ]
            ),
        ),
    );
}

Any idea?

gohanko commented 4 years ago

Adding to this, I tried to compile the example's flutter project and reached the same problem with the images of https://www.gutenberg.org/ebooks/11.epub.images and https://www.gutenberg.org/ebooks/19002.epub.images not being displayed.

angel-afonso commented 4 years ago

I had the same problem for some epub files, I am trying to load the cover image of about 10 e-books and only one of them shows a cover image