Flutter hide keyboard when clicking outside text input

If you are a flutter developer then you must face this issue. Here is a simple solution for this.

Just wrap your while widget with GestureDetector and unfocus the primary focus on tapping it. Let’s see the code to make it clear

body: GestureDetector(
    onTap: () {
    FocusScope.of(context).requestFocus(new FocusNode());
    },
    child: Stack(
        // Other widgets here
    )
)

Happy coding 🙂