Flutter Dialog点击阴影区域,隐藏keyboard

Flutter Dialog弹窗内容区域存在TextField,当Keyboard显示时点击空白区域隐藏keyboard同时 不 dismiss Dialog.

    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: () {
        // print('>>> 点击了 ' + DateTime.now().millisecondsSinceEpoch.toString());
        FocusScope.of(context).requestFocus(FocusNode());
      },
      child: UnconstrainedBox(
        child: Padding(
          padding:
              EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
          child: GestureDetector(
            onTap: () {},
            child: SizedBox(
              width: 2 * 300.w,
              child: Material(
                shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.all(Radius.circular(4))),
                child: dialogChild,
                color: Colors.white,
              ),
            ),
          ),
        ),
      ),
    );

你可能感兴趣的:(Flutter Dialog点击阴影区域,隐藏keyboard)