Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter TextField get Selected Text

In android we can get the starting and ending index of selected text in an EditText using this :

int a = inputET.getSelectionStart();
int b = inputET.getSelectionEnd();

What is the flutter alternative for this in a TextField ?

like image 880
Femin Dharamshi Avatar asked Mar 04 '23 20:03

Femin Dharamshi


1 Answers

It can be a bit more straightforward than Fayaz's answer: with a TextField(controller: _textEditingController) one can access the selected text like this:

_textEditingController.selection.textInside(_textEditingController.text)
like image 166
mckbrd Avatar answered Mar 16 '23 08:03

mckbrd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!