Is there an option to select the text written in TextFormField or TextField on double clicking the field in a Windows App made in Flutter?

Because currently it only works if the text is double clicked, whereas normally in windows application clicking anywhere in the text field selects the entire text written.


Solution 1: Kaushik Chandru

Wrap the textfield with an inkwell to provide a double tap. Then on double tap set the selection of the textfield

InkWell(
 onDoubleTap:(){
   setState((){
      _textController.selection = TextSelection(baseOffset:0, extentOffset: _textController.text.length);
   });
  },
 child:TextField(
  controller: _textController,
 )
)


Solution 2: Amroun

Put your TextField inside GestureDetector

GestureDetector(
   onDoubleTap:() {
     if(_controller.text.isNotEmpty) {
       _controller.selection = TextSelection(baseOffset: 0, extentOffset:_controller.text.length);
     }
   },
   child: TextField(controller: _controller, ),
)