TextField( controller: TextEditingController.fromValue(TextEditingValue( // 设置内容 text: inputText, // 保持光标在最后 selection: TextSelection.fromPosition(TextPosition( affinity: TextAffinity.downstream, offset: inputText.length)))), )