KV Santhosh
KV Santhosh

Reputation: 33

How to get selected text from SelectableText widget in flutter

I'm using SelectableText widget to make Text selectable. But I don't know how to get the selected text and log it to console.

Upvotes: 1

Views: 2114

Answers (1)

Andrei
Andrei

Reputation: 330

You can add the ToolbarOptions inside your SelectableText with copy: true and then read the data from the clipboard.

SelectableText(
  'your text',
  toolbarOptions: ToolbarOptions(copy: true)
);

Here is an answered question about the clipboard: Flutter can't read from Clipboard

Edits: Clean up the answer and add more info.

Upvotes: 1

Related Questions