Closed umutoney closed 2 years ago
Selectable text is very useful but unfortunately it cannot be done with SelectableText.rich
because it does not support non-TextSpan
children which is used by this plugin to render inline image.
https://api.flutter.dev/flutter/material/SelectableText/SelectableText.rich.html
The textSpan parameter must not be null and only contain TextSpan in textSpan.children. Other type of InlineSpan is not allowed.
Reconsider SelectableText
support when this issue is closed: https://github.com/flutter/flutter/issues/38474
You could use https://github.com/fluttercandies/extended_text
https://github.com/flutter/flutter/issues/38474#issuecomment-862130308
SelectableText is actually built on top of EditableText internally, which means that the core WidgetSpan support added for
flutter/flutter#30688
which landed influtter/flutter#83537
may have also allowed SelectableText to support WidgetSpans. I will check if this is indeed true.If anyone has a particular use case, please try passing WidgetSpans to the SelectableText.rich() constructor and see if it behaves as you expect.
Wow 🤯
It works!
Does this mean that we'll have selectable text on flutter_html_widget ? 🤩
Does this mean that we'll have selectable text on flutter_html_widget ? 🤩
Yes 🚀
Great to hear that this feature will be possible in the future. Can you give an estimation how well it works? 😃
Currently we have to create a div tag with a custom class and da widget factory for coupons to make them copyable.
Current it works with simple test cases and doesn't with HTML that has deep nested stylings. I ran a few quick tests so I didn't dig any further. Once the bugs are ironed out, I think it should be fairly stable.
@daohoangson Any update on this?
The reference commits haven't reached stable yet. They are in beta though, that's some progress.
Flutter 2.5 has been released with support for WidgetSpan
in SelectableText
. Expect a new version soon.
It works on stable but Flutter source code modification is still required. The assertion should be removed sometime soon (I hope). Will keep a close eye on this.
This is very important to me. I'm glad to hear about the progress. Is there special code to write to make this happen. I'm confused when a different widget (SelectableText.rich) is mentioned, unless that is used internally in wrapped code.?
Very simple tests have been done to verify selectable widget but it's not usable yet. We will have to wait.
What is the approximate time projection for this feature?
It depends entirely on the Flutter team, I'm asking at https://github.com/flutter/flutter/issues/38474#issuecomment-932849890
.
The Flutter team has removed the restriction on master channel, it should make it way to dev channel in a few days.
The Flutter team has removed the restriction on master channel, it should make it way to dev channel in a few days.
hi, still waiting for support
I am also pretty excited to finally be able to have this -- I tried passing paragraphs to use SelectableText
and while I can't select separate paragraphs, it's really promising to just see this finally work on master. Is there a fork of the package with the text with factories already set up to have SelectableText
I can try out?
Looks like it's available in the 2.8.0 beta 3 days ago https://github.com/flutter/flutter/releases/tag/2.8.0-3.1.pre, let me release a new version with this real quick.
v0.8.3-beta.1
has been released. The new parameter works like this:
HtmlWidget(
html,
isSelectable: true, // default is false
)
There is a live demo link available in the PR: https://github.com/daohoangson/flutter_widget_from_html/pull/631. There are still issues like selecting across multiple paragraphs etc.
Thanks for this! I will test this tomorrow. Which version or branch of Flutter do we need for this?
You need at least 2.7, currently in beta channel.
Is there a way to have the popup disabled and also a callback when there is a selection? and special wish is to have a callback on word click (as if every word were a url).
Our webview project does this.. https://play.google.com/store/apps/details?id=com.paauk.tipitakapalireader We want to migrate out of webview and into this package so we can do desktop.
You want to disable the selectable popup? Err, you can disable selectable mode for that I guess.
Technically you can register all sort of gesture recognizer on the widgets and texts. But doing so for everything may hurt performance 🤔 Please open a separate discussion for this if you want to discuss further.
v0.8.3+1
has been released with support for isSelectable
in the flutter_widget_from_html
package. The core package is not updated at this time to avoid bumping the minimum required Flutter version. v2.8 stable is pretty new.
I'm closing this two-year-old issue right now, please open new issue if you encounter bugs related to this feature.
Can this be augmented with the newly released SelectionArea in Flutter 3.3? Makes selecting multiple paragraphs possible!
Should be. I'm working on it here https://github.com/daohoangson/flutter_widget_from_html/pull/821. Ideally HtmlWidget
should work automatically if it is built within a selection area.
okay.. sadhu x 3 (appreciated). Because of you, we moved forward to 5 OS.
https://master-api.flutter.dev/flutter/material/SelectableText-class.html