Search code examples
flutterflutter-webflutter-text

Flutter: Make text/images selectable in whole web app


In the Flutter web apps, there is no default functionality which makes text and images in the app selectable.

Is there a way to enable selection functionality for text/image on web?

I did check SelectableText widget but it is only for text and I would need to use it over every text. Also, you can't select text in multiple SelectableText widgets at once, you can only select text in one of them. I'm looking for a solution to select all text in the app without making change to every text widget.

Let me know if there’s one step solution to achieve this thing in whole web app.


Solution

  • In Flutter 3.3, with the introduction of the SelectionArea widget, any child of the SelectionArea widget has selection enabled for free!

    enter image description here

    To take advantage of this powerful new feature, simply wrap your route body (such as the Scaffold) with the SelectionArea widget and let Flutter do the rest.

    For a more comprehensive deep dive into this awesome new feature, please visit the SelectionArea API page.