flutter_widget_from_html icon indicating copy to clipboard operation
flutter_widget_from_html copied to clipboard

Split very long content into pages

Open SoFo12 opened this issue 4 years ago • 7 comments

I have multiple html files with very long text which I would like to split into pages to make it easier to read and navigate. Here's an example of this: image Can I change the widget to implement similar? And scrollview does not fit.

SoFo12 avatar Mar 02 '20 12:03 SoFo12

I think you can split with with regular expression or similar before rendering each page HTML? That should be simple enough.

daohoangson avatar Mar 02 '20 16:03 daohoangson

but I don’t know how long html will be

SoFo12 avatar Mar 02 '20 16:03 SoFo12

Ah, you want to split pages by actual rendering height? Are you developing an eBook reader or similar?

daohoangson avatar Mar 03 '20 00:03 daohoangson

Ah, you want to split pages by actual rendering height? Are you developing an eBook reader or similar?

Yes

SoFo12 avatar Mar 03 '20 11:03 SoFo12

@SoFo12 were you able to find a solution? I am currently working on a custom epub library, so I am interested in how this could be done.

For reference, J-Novel Club has implemented a basic paged html reader in their Flutter mobile app, and the text is selectable. Judging from their open source libraries list, they did not use one of the html packages on pub.dev. This gives me hope it can be done without a webview.

getBoolean avatar Oct 22 '22 07:10 getBoolean

@SoFo12 @getBoolean Any Update on this. Currently I have only very bad working solutions (perfomance wise)? I am currently working on an E-Book Reader (diffrent formats) too. https://github.com/FlafyDev/epub_reader/ has one solution, but it´s using webview so not useable for my needs

Vito0912 avatar Apr 20 '23 10:04 Vito0912

@Vito0912 only thing I could think of was to iterate through the html and render one section at a time and measure, then add more text via post frame callbacks and repeat until no more can be added. Obviously, this would look pretty laggy so it is not a real option.

The crux of the problem is that we need to know the height of the widget before it is rendered to determine the amount of text, but this is inherently orthogonal to Flutter's layout system. This needs to be handled at a lower level to work, possibly with render objects. I've toyed around with render objects for this, but I haven't been able to come up with anything concrete.

getBoolean avatar May 25 '23 04:05 getBoolean