Last active
August 29, 2021 15:29
-
-
Save mingsai/32461fc93d176eb3ee9f8e6f7935d94c to your computer and use it in GitHub Desktop.
Flutter - dismiss keyboard on tap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//wrap the layout widget for the screen with a Gesture detector having this function | |
GestureDetector( | |
onTap: () { | |
FocusScopeNode currentFocus = FocusScope.of(context); | |
if (!currentFocus.hasPrimaryFocus) { | |
currentFocus.unfocus(); | |
} | |
}, | |
child; Container(), | |
), | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment