FLUTTER ECOSYSTEM

drogel/keyboard_dismisser

ジェスチャーをキーボード外で実行したときにキーボードを非表示にする簡単なFlutterパッケージ。

keyboard_dismisser のプロジェクト画像
Stars
50
Forks
13
最終プッシュ(UTC)
2022/06/09
プロジェクト状態
公開中
Diego Rogel GitHub avatar
GITHUB User

Diego Rogel ↗

iOS engineer at @feverup and Vim enthusiast. iOS, Flutter, Swift, Dart, Bash, macOS.

@feverupSpain
言語DartHTMLSwiftKotlinObjective-C

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 2 件
  • flutter{"sdk":"flutter"}
  • flutter_test開発用{"sdk":"flutter"}

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

README を開く / 閉じる

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.