dart – 以编程方式关注InputField并打开键盘

dart – 以编程方式关注InputField并打开键盘,第1张

概述我有一种情况,我需要以编程方式专注于 InputField(例如响应按钮按下). 我正在使用Focus.moveTo功能;但是,即使InputField处于聚焦状态(出现闪烁的光标),键盘也不会启动. 似乎最好的解决方案是在_InputFieldState中调用RequestKeyboard()函数,但这是私有的. 实现这一目标的最佳方法是什么? 以下是显示工作流程的代码示例: class Inp 我有一种情况,我需要以编程方式专注于 InputField(例如响应按钮按下).

我正在使用Focus.moveTo功能;但是,即使inputFIEld处于聚焦状态(出现闪烁的光标),键盘也不会启动.

似乎最好的解决方案是在_inputFIEldState中调用RequestKeyboard()函数,但这是私有的.

实现这一目标的最佳方法是什么?

以下是显示工作流程的代码示例:

class inputFIElDWrapper extends StatefulWidget {  @overrIDe  _inputFIElDWrapperState createState() => new _inputFIElDWrapperState();}class _inputFIElDWrapperState extends State<inputFIElDWrapper> {  inputValue _currentinput = new inputValue(text: 'hello');  // GlobalKey for the inputFIEld so we can focus on it  GlobalKey<EditableTextState> _inputKey = new GlobalKey<EditableTextState>();  @overrIDe  Widget build(BuildContext context) {    return new Column(      children: [        // button that should focus on the inputFIEld when pressed        new Iconbutton(          icon: new Icon(Icons.message),onpressed: () {            Focus.moveto(_inputKey);          },),// inputFIEld that should be focused when pressing the button        new inputFIEld(          value: _currentinput,key: _inputKey,onChanged: (inputValue input) {            setState(() {              _currentinput = input;            });          }        ),],);  }}
解决方法 这被认定是一个错误,并在 #7985被跟踪. 总结

以上是内存溢出为你收集整理的dart – 以编程方式关注InputField并打开键盘全部内容,希望文章能够帮你解决dart – 以编程方式关注InputField并打开键盘所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1001828.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-22
下一篇2022-05-22

发表评论

登录后才能评论

评论列表(0条)

    保存