Search packages, repositories and app categories

keyboard_dismisser cover
Package detailsv3.0.0

keyboard_dismisser

A simple Flutter package to hide the keyboard when performing a gesture outside of it.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
31.8K
Likes
247
Pub points
160

Install package

flutter pub add keyboard_dismisser

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A lightweight Flutter package that automatically dismisses the keyboard when the user taps outside of any text input field. It enhances user experience by providing a seamless way to close the keyboard without requiring a dedicated button or manual action. The package works across all major platforms, including mobile, web, and desktop, making it ideal for forms and input-heavy interfaces. It integrates easily with existing widgets and requires minimal setup.

Use cases

  • Form inputs with frequent keyboard toggling
  • Mobile and web apps needing intuitive keyboard dismissal
  • Desktop applications with text fields
  • Improving UX in chat or messaging interfaces
  • Reducing clutter by eliminating extra close buttons

Key features

  • Automatic keyboard dismissal on tap outside
  • Cross-platform compatibility
  • Minimal code integration
  • Supports all input types
  • No additional dependencies

Suitable for

  • Developers seeking simple keyboard management
  • Apps with multiple text fields
  • UX-focused application design
  • Projects targeting multiple platforms

Considerations

  • May interfere with other gesture detectors
  • Not suitable for complex gesture interactions
  • Requires careful placement in widget tree
  • Limited customization options
  • Does not handle keyboard visibility programmatically

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

keyboard_dismisser

A simple Flutter package to hide the keyboard when performing a gesture outside of it.

Pub

Example

Features

  • 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 GestureDetector.
  • 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.

Usage

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, KeyboardDismisser will dismiss the keyboard when tapping outside of it, but it handles several gestures at the same time.

    Widget build(BuildContext context) => KeyboardDismisser(
        gestures: [GestureType.onTap, GestureType.onPanUpdateDownDirection],
        child: Scaffold(
            body: ...,
        ),
      );

Getting started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  keyboard_dismisser: "^[LATEST_VERSION]"

Then run $ flutter pub get. In your library, add the following import:

import 'package:keyboard_dismisser/keyboard_dismisser.dart';

Author

Diego Rogel - GitHub

Changelog

Check the Changelog page to see what's recently changed.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Categories

Source repository

Projects using this package