A simple Flutter package to hide the keyboard when performing a gesture outside of it.
- By default, dismisses the keyboard when tapping outside of it on an inactive widget.
- Supports several gestures at the same time.
- Supports all the gestures available in Flutter's
- Supports directional swipes to dismiss the keyboard.
- Can be applied to a whole page by wrapping its Scaffold.
- Can be applied to a whole app, by wrapping its MaterialApp, WidgetsApp, or CupertinoApp.
- Customizable drag start behavior and gesture hit testing behavior.
- Can be excluded from the semantics tree.
This package exposes a
KeyboardDismisser stateless widget. You can wrap your widget with it, and
your widget will be able to dismiss the keyboard when performing a gesture.
Widget build(BuildContext context) => KeyboardDismisser( child: Scaffold( body: ..., ), );
KeyboardDismisser takes a
gestures parameter, which is a list of
GestureType enum cases. This
way, you can pass any gesture you like for the keyboard dismissal. By default,
will dismiss the keyboard when tapping outside of it, but it handles several gestures at the
Widget build(BuildContext context) => KeyboardDismisser( gestures: [GestureType.onTap, GestureType.onPanUpdateDownDirection], child: Scaffold( body: ..., ), );
pubspec.yaml of your flutter project, add the following dependency:
dependencies: keyboard_dismisser: "^1.0.0"
$ flutter pub get. In your library, add the following import:
Diego Rogel - GitHub
Check the Changelog page to see what's recently changed.
This project is licensed under the MIT License - see the LICENSE.md file for details.