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.
1 Answer
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.
2 Comments
KV Santhosh
Thanks @Andrei Caisim. Is there any way to make this by default...i mean when user tap on the text, instead of poping copy button, by default it should copy.
Andrei
I don't know if this is possible, as I cannot see any controller or listener that listens to how much of the text is selected.