Sub6Resources / flutter_html

A Flutter widget for rendering static html as Flutter widgets (Will render over 80 different html tags!)
https://pub.dev/packages/flutter_html
MIT License
1.8k stars 874 forks source link

[QUESTION] img in SelectableHtml #1154

Closed Szymon-Gesicki closed 1 year ago

Szymon-Gesicki commented 2 years ago

Hi I have a question regarding "SelectableHtml". I found a comment in the code.

  /// 1. The list of tags that can be rendered is significantly reduced.
  /// Key omissions include no support for images/video/audio, table, and ul/ol because they all require widgets and `WidgetSpan`s.

Will there ever be support for images? I don't mean selecting photos just the ability to display them. I tried "customRenders" but it doesn't help in tags there are no image, when I added it I get an error that "WidgetSpan" is not supported. Are there plans to add this and when?

erickok commented 2 years ago

Not right now, due to past limitations in Flutter. However I with the introduction of SelectableRegion you might not need SelectableHtml any more and we might even deprecate SelectableHtml altogether because of it. So give it a try!

Szymon-Gesicki commented 2 years ago

Thanks a lot for the reply, is there anyone who has already used "SelectionArea" or "SelectableRegion" along with html? I tried it, I put the widget "Html" in "SelectableRegion" or "SelectionArea" and I get a bunch of errors :

Failed assertion: line 1423 pos 12: 'word.start >= range.start && word.end <= range.end'

The "h1" tag works great but when I try to select for example "p" I get these errors. Anyone tried?

I found this error in the dart code and it says:

    // Fragments are separated by placeholder span, the word boundary shouldn't
    // expand across fragments.

someone can help?

erickok commented 2 years ago

Hmm intersting. Yes I tried it a bit with a simple bit of html, consisting od some paragraphs and a table and an image and it worked for me. Might be a glitch of limitation of SelectionArea... not sure. Can you share some but of Html that doesn't work for you?

BTW it's SelectionArea not SelectableRegion which is a different thing.

Szymon-Gesicki commented 2 years ago

This may be a problem because I use your library to show the book "epub". I found a short example that gives me this error. After trying to select the text "TRY COPY ME" I get the error I sent above.

html:

<html>
    <body>
        <div>
            <p>TRY COPY ME</p>
        </div>
    </body>
</html
Sub6Resources commented 1 year ago

Closing, since SelectableHtml has been removed as of 3.0.0-beta.1.

Please wrap your Html widget in a SelectionArea widget provided by Flutter.

Nohchiadam commented 1 year ago

Have you solved this problem? My text shrinks when selected. And he gets up against each other. I use

with style.