Im-Kevin / cool_ui

用flutter实现一些我认为好看的UI控件,有Popover,仿Weui的Toast,自定义键盘
Apache License 2.0
460 stars 74 forks source link

自定义的键盘按返回键时会促发TextField onSubmitted #28

Closed zhangtengchao closed 3 years ago

zhangtengchao commented 5 years ago

如题,在你的Demo例子上, TextField( decoration: InputDecoration(labelText: '演示键盘弹出后滚动'), keyboardType: NumberKeyboard.inputType, onSubmitted: (txt){ print('aaaaaaaa'); }, ), TextField( decoration: InputDecoration(labelText: '多个键盘演示'), keyboardType: TestKeyboard.inputType, onSubmitted: (txt){ print('bbbbbbb'); }, ) 加上onSubmitted,当键盘弹出时,按返回键,就会自动促发onSubmitted

Im-Kevin commented 4 years ago

这个是flutter自带的效果

science168 commented 4 years ago

如上面所提到的, onSubmitted问题. 安卓物理返回键会触犯onSubmitted. 但跟踪代码好像是内部处理物理返回键 // BackButtonInterceptor.add((_) { // CoolKeyboard.sendPerformAction(TextInputAction.done); // return true; // }, zIndex: 1, name: 'CustomKeyboard'); } // BackButtonInterceptor.removeByName('CustomKeyboard');

Im-Kevin commented 4 years ago

是的,这个是模仿原生键盘的操作