flutter 点击回车(return)键 禁止键盘下落
2023-02-16 本文已影响0人
writeSpace
实现 onEditingComplete即可
flutter键盘 return 键回调 实现这个方法之后 点击键盘将不会下落
new TextField(
// textInputAction:TextInputAction.newline,
onEditingComplete: (){
// FocusScope.of(context).requestFocus(_backNode);
// FocusScopeNode focusScopeNode = FocusScope.of(context);
// // if (!focusScopeNode.hasPrimaryFocus &&
// // focusScopeNode.focusedChild != null) {
// FocusManager.instance.primaryFocus!.unfocus();
// }
print('onEditingComplete11111');
},
onTap: () {
print("ohao ");
},
// focusNode: _backNode,
// onSubmitted: (String str) {
// //onSubmitted是用户提交而触发的回调{当用户点击提交按钮(输入法回车键)}
// print('最终手机号为:$str---------------');
// },
controller: _userPasswordController,
keyboardType: TextInputType.multiline,
decoration: new InputDecoration(
contentPadding: const EdgeInsets.all(10.0),
icon: new Icon(Icons.nature_people),
labelText: "请输入名字",
// hintText: "fdsfdss",
helperText: "注册名字"),
),