[英]Using Flutter, how can I trigger onSubmitted() of TextField on iOS?
Please take a look at the following Flutter code snippet: it creates a TextField
that is intended as a single line input field tat will submit its value when Return is pressed: 请看下面的Flutter代码片段:它创建一个
TextField
,用作单行输入字段,当按回车键时tat将提交其值:
child: new TextField(
decoration: _deco,
maxLines: 1,
autofocus: true,
onSubmitted: (newValue) {print(newValue);},
onChanged: (newValue) {
setState(() {
strTemperature = newValue.trim();
});
})),
On the iOS Simulator the corresponding app looks as follows: 在iOS Simulator上,相应的应用程序如下所示:
As you can see the widget is configured with maxLines = 1
, but when I click the Return key on the onscreen keyboard, line feeds are insert. 如您所见,该窗口小部件配置了
maxLines = 1
,但是当我单击屏幕键盘上的Return键时,将插入换行符。 Please spot the narrow blue cursor a couple of lines below the widget. 请在小部件下方的几行中找到狭窄的蓝色光标。 Also, I see no console output, which should be the case because of my
onSubmitted()
lambda. 另外,我看不到任何控制台输出,由于我的
onSubmitted()
lambda,应该是这种情况。
Am I configuring the text field correctly, or am I missing something? 我是否正确配置了文本字段,还是缺少某些内容?
This looks to me like it's actually just a bug in the iOS version of Flutter. 在我看来,这实际上只是Flutter的iOS版本中的错误。 Filed issue #9839 .
提起的问题#9839 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.