简体   繁体   English

使用Flutter,如何在iOS上触发TextField的onSubmitted()?

[英]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.

相关问题 如何使用 Flutter 中的 onSubmitted 导航到另一个小部件 - How can I navigate to another widget by using onSubmitted in Flutter 如何在提交时将文本字段更改为另一个小部件? - How can I change a Textfield to another widget onSubmitted? Flutter:onEdittingComplete 和 onSubmitted 之间的 TextField 差异 - Flutter: TextField difference between onEdittingComplete and onSubmitted 如何使用颤振中的文本字段制作数字计数器应用程序? - How can I make a number counter app using textfield in flutter? 如何将flutter textFormField onChange和onSubmitted作为参数传递? - How to pass flutter textFormField onChange and onSubmitted as a parameter? 如何将数据发送到 flutter 中的文本字段 - How can i send data to textfield in flutter 我如何在发短信 flutter 时使用向上和向下箭头从文本字段建议 select - how can i select suggestion from textfield using up & down arrow while texting flutter 如何在颤动的文本字段中启用选项卡(web 版本)? - How can I enable Tab in Textfield of flutter( web version)? 如何通过警报对话框文本字段在列表视图中添加项目? 在 flutter - how can I add an item in listview by alert dialog textfield? in flutter Flutter & Textfield :如何通过自动删除该空间来限制我的用户使用文本字段中的空间? - Flutter & Textfield : How do I restrict my user from using space in textfield by automatically removing that space?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM