Closed zhangtengchao closed 3 years ago
这个是flutter自带的效果
如上面所提到的, onSubmitted问题. 安卓物理返回键会触犯onSubmitted. 但跟踪代码好像是内部处理物理返回键
// BackButtonInterceptor.add((_) { // CoolKeyboard.sendPerformAction(TextInputAction.done); // return true; // }, zIndex: 1, name: 'CustomKeyboard'); } // BackButtonInterceptor.removeByName('CustomKeyboard');
是的,这个是模仿原生键盘的操作
如题,在你的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