First, we need to define a TextEditingController in the Page's class
TextEditingController _content = new TextEditingController();
Then, bind the TextEditingController to the TextField
TextField(controller: _content)
Finally, place the code in the button
new FlatButton( onPressed: () { _content.selection = TextSelection(baseOffset: 0, extentOffset: 2); })
Note that baseOffset refers to the starting position, and extentOffset refers to the end
The code here selects from the 0th to the 2nd character, with the following effect