Currently, I know the method of hiding the soft keyboard using this code, by onTap
methods of any widget.
FocusScope.of(context).requestFocus(new
If you want to do this "the right way", use Listener instead of GestureDetector.
GestureDetector will only work for "single taps", which isn't representative of all possible gestures that can be executed.
Listener(
onPointerDown: (_) {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.focusedChild.unfocus();
}
},
child: MaterialApp(...),
);