fluttermobileepub

How read Epub in Flutter?


So, I can parse epub files to html through epub-dart(https://pub.dev/packages/epub). But, there are some way to read epub in flutter more easily?

It's because I need to be able to select text, like Selectable Text widget, but if I just use flutter_html, I'm not able to select text.

Can someone help me? Thanks!!


Solution

  • You could use the customRender callback as documented here. It is a paramter of the Html constructor. Perhaps you can

          customRender: {
            "div": (RenderContext context, Widget child, attributes, _) {
              if(child is Text) {
                child = SelectableText(child.data);
              }
              return Container(child: child);
            },
          },
    

    Unfortunately the customRender callback does not support patterns or anything so you would probably have to list all potential elements containing text like, li, h1,h2,div,span etc.