使用EditableText颤振 [英] Flutter using EditableText
问题描述
我试图弄清楚如何在Flutter中使用TextEditor.
I'm trying to figure out how to use the TextEditor in Flutter.
我有卡片编辑器"(基本上我希望能够处理一段文本)
I have "Card Editor" (basically I want to be able to work on the equivalent of a paragraph of text)
new EditableText(
autofocus: true,
maxLines: null,
backgroundCursorColor: Colors.amber,
cursorColor: Colors.green,
style: TextStyle(),
focusNode: FocusNode(),
controller: controller,
onSubmitted: (val) {
_addCard(val);
Navigator.pop(context);
},
)
我是从TextField的示例中改编而成的.
I adapted this from an example of a TextField.
但是我有几个问题.
首先,当我键入内容时,它似乎什么也没显示.光标移动,但是看不到任何文本.没有显式样式时,这是默认值吗?
Firstly, it doesn't seem to show anything when I type. The cursor moves, but no text is visible. Is that the default when there's no explicit style?
第二,如何触发提交?使用TextField,CR/Enter按钮可以执行此操作.显然,我明白了为什么您不一定要使用EditableText,但是我应该怎么做呢?
Secondly, how do I trigger the submit? With a TextField, the CR / Enter button does this. Obviously I see why you don't necessarily want that with EditableText But what should I do instead?
第三,我需要能够将默认文本放入此小部件.我尝试向EditableText添加值"属性,但这似乎不正确.这是怎么做的?
Third, I need to be able to put default text into this widget. I tried adding a "value" attribute to the EditableText, but that doesn't seem to be right. What's the way to do this?
推荐答案
-
,来自 TextField类-材质库-Dart API :
EditableText ,它是TextField核心的原始文本编辑控件.除非您要实现完全不同的设计语言(例如Cupertino),否则很少直接使用EditableText小部件.
EditableText, which is the raw text editing control at the heart of a TextField. The EditableText widget is rarely used directly unless you are implementing an entirely different design language, such as Cupertino.
这篇关于使用EditableText颤振的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!