![](/img/trans.png)
[英]Highlight text in different colors - TextField in Flutter
[英]How to set different colors for different lines of text in a Flutter textfield?
我正在嘗試創建一個文本機器人,我需要該機器人的 output 具有不同的顏色。 而且我需要文本是可編輯的,所以它需要在文本字段中。 目前,當我收到 output 時,我將文本字段文本設置為更新后的 output。
文本字段的代碼:
child: TextField(
controller: textFieldController,
expands: true,
maxLines: null,
style: const TextStyle(
color: Colors.blue,
),
decoration: const InputDecoration(
border: InputBorder.none,
hintText: 'Enter prompt',
hintStyle: TextStyle(
color: AppColors.darkText,
fontSize: 20,
),
),
),
設置TextField文本的代碼
conversationList.add(output);
conversation = conversationList.join("");
textFieldController.clear();
textFieldController.text = conversation;
我已經嘗試過像detectable_text_field這樣的包,但它不起作用,因為 output 發生了變化。
我認為你只能使用富文本編輯器。 嘗試使用flutter_quill
package。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.