orthros / dart-epub

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

EpubByteContentFileRef.readContent() to return Future<Uint8List> #32

Closed lastant closed 5 years ago

lastant commented 6 years ago

With an older version of flutter 0.5.1 and epub 1.3.2 I could load an image in a the Image widget with EpubByteContentFileRef.readContent() and Image.memory(...). But with the latest flutter dev version 0.5.8 and epub 2.0.2 there is an exception: type 'List<int>' is not a subtype of type 'Uint8List'

orthros commented 6 years ago

Can you give a more detailed description? Full disclosure: it has been a long time since I have worked with flutter.

It sounds like you are trying to something like

EpubBook epubRef = await EpubReader.readBook(bytes);
Image img = Image.memory(epubRef.CoverImage.getBytes());

Is that correct?

lastant commented 6 years ago

No, the CoverImage has class Image from the dart image package, and its getBytes() method does return a Uint8List. I want to display images from the content: epubRef.Content.Images[imgHref].readContent() , and this function returns List<int>

lastant commented 6 years ago

The current workaround for me is to use Uint8List.fromList(), but it apparently copies the original array and might be slow for big images.

lastant commented 6 years ago

https://github.com/brendan-duncan/archive/issues/55#issuecomment-418233496

orthros commented 5 years ago

I recommend looking at the example in the examples/flutter_ex folder. This shows how to get the image rendered in a Flutter application