
我正在使用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并打开键盘所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)