I want to hide the keyboard when the user taps outside of a TextField
. My current solution is to listen to taps in a GestureDetector
that wraps the screen and call FocusScope.of(context).unfocus()
to hide the keyboard.
The problem is that the GestureDetector
doesn't detect taps on widgets like buttons. So when a button is tapped, the keyboard doesn't hide.
Container
and wrap it inside yourGestureDetector
. Is that what you're looking for? – GlossographyGestureDetector
, which is supposed to hide the keyboard on touches outside a text field. – PortmanteauNSLayoutConstraint
error in the iPhone simulator. If I had the time I would probably try to create a custom widget which detects taps on focusable widgets, perhaps by overriding thehitTest
method inRenderBox
. – Portmanteau