How to tap to copy html text in flutter app

2.1k Views Asked by At

My developer is building an educational app for me and we kind of have a problem. I want to know how to tap a word or phrase on the screen to show copy, highlight, web search like the image below. The app was built with flutter and the code is in dart. This feature is really needed. Will appreciate if someone can help with a plugin or just a way to do this.

enter image description here

5

There are 5 best solutions below

2
Adelina On

Flutter has selectable text for that

If he is using webview, maybe this could help? How to enable text selection modal(copy/paste/select) in flutter webview?

2
Mustafa yıldiz On

They is a package for copy and paste text in the flutter.

FlutterClipboard.copy(item.code).then((value) {})

package link

0
Saiful Islam On

Well I got your problem.

There is a possible solution. Here you are doing is sending data from server in html format and displayed it using html_viwer. But there is no functionality I found to select and copy so far.

The possible solution is send string data from server and use SelectableText() to show the text and you will be able to select and copy your text.

1
Pedro Pinto On

There's a solution for this, just use SelectableHtml widget instead of only Html

0
Sadiq Hussain On

If you are using webview package you have a gestureRecognizers property in webview widget, just add this line:

WebViewPlus(
  gestureRecognizers: {}..add(Factory<LongPressGestureRecognizer>(() => 
     LongPressGestureRecognizer())),...)