- 父布局关闭键盘+返回键监听
GestureDetector(
onTap: () {
///关闭弹框
FocusScope.of(context).requestFocus(FocusNode());
},
child: Scaffold(
appBar: WidgetUtils.showAppar(context, '标题', onBackCall: () {
_showExitDialog();
}),
///使用WillPopScope监听返回键
body:WillPopScope(
onWillPop: () async {
if (Theme.of(context).platform == TargetPlatform.android) {
_showExitDialog();
}
return true;
},
child: Container(
color: Colours.color_white,
),
),
);
- 点击失效
给GestureDetector的child添加背景色,才能有反应
GestureDetector(
onTap: () {
}