flutter-全局点击空白回收键盘
2020-12-01 本文已影响0人
ChaosHeart
///build
@override
Widget build(BuildContext context) {
//配置全局点击空白回收键盘
return GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus &&
currentFocus.focusedChild != null) {
FocusManager.instance.primaryFocus.unfocus();
}
},
child: initDefaultBuild(context));
}