Flutter点击空白处取消TextField焦点(收起软键盘)

GestureDetector(
    behavior: HitTestBehavior.translucent,
    onTap: () {
        // 触摸收起键盘
        FocusScope.of(context).requestFocus(FocusNode());
    },
    child: ****视图内容***
}

把GestureDetector放在body最外层

你可能感兴趣的:(Flutter点击空白处取消TextField焦点(收起软键盘))