Flutter TextField set default value Default value and the cursor position

The main controller implemented by the specific code as follows

TextField(
          //输入键盘类型 keyboardType: TextInputType.text, autofocus: true, decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(
30), borderSide: BorderSide.none), ), onChanged: (value) { this._keyword = value; }, controller: TextEditingController.fromValue(TextEditingValue( text: '${this._keyword == null ? "" : this._keyword}', //Determining whether the keyword is empty // remains at the last cursor Selection: TextSelection.fromPosition (TextPosition ( Affinity: TextAffinity.downstream, offset: ' $ {} this._keyword ' .length)))), ),

 

Guess you like

Origin www.cnblogs.com/yjpjy/p/11504522.html