govind
govind

Reputation: 158

How to enable text selection modal(copy/paste/select) in flutter webview?

Can anyone please share the code snippet to enable the text selection model in the webview of the flutter? Till now I get that by default webview only has one gesture recognizer i.e. vertical scrolling. If anyone have code for LongPressGestureRecognizer please share it here. Thanks in advance.

Upvotes: 6

Views: 3914

Answers (2)

Syed Laiq Afzal
Syed Laiq Afzal

Reputation: 84

Just add gestureRecognizers property in WebView widget, and then you will be able to long press on WebView content example:

   

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

Upvotes: 5

govind
govind

Reputation: 158

It was solved by changing the webview package. Currently I am using flutter_inappwebview package and it's working fine. The thing was the previous webview package didn't support the touch and hold gestures. Also, native webview for Android and iOS could also be used but no overlay can be shown in that case.

The above package works fine on both cases.

Upvotes: 0

Related Questions