Skip to content

Instantly share code, notes, and snippets.

@mingsai
Last active August 29, 2021 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mingsai/32461fc93d176eb3ee9f8e6f7935d94c to your computer and use it in GitHub Desktop.
Save mingsai/32461fc93d176eb3ee9f8e6f7935d94c to your computer and use it in GitHub Desktop.
Flutter - dismiss keyboard on tap
//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