1分钟
17 键盘焦点处理
一般触摸收起键盘也是常见需求,如下代码所示, GestureDetector
+ FocusScope
可以满足这一需求。
class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
///定义触摸层
return new GestureDetector(
///透明也响应处理
behavior: HitTestBehavior.translucent,
onTap: () {
///触摸手气键盘
FocusScope.of(context).requestFocus(new FocusNode());
},
child: new Container(
),
);
}
}
学员评价