搜索插件、代码仓与 APP 分类

插件详情v0.5.6

keyboard_visibility

用于在 Android 和 iOS 上发现软键盘可见性状态的 Flutter 插件。

近 30 天下载
735
喜欢数
122
Pub 分数
35

安装插件

flutter pub add keyboard_visibility

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

keyboard_visibility 包是一个 Flutter 插件,可让开发者检测 Android 和 iOS 设备上软键盘的可见状态。它提供了一个简单的 API 来监听键盘显示/隐藏事件,使应用程序能够动态响应——例如调整布局或滚动内容以进入视图。这在表单或聊天界面中特别有用,因为用户输入需要视觉反馈。该插件跨平台无缝工作,设置简单,非常适合响应式 UI。

适合场景

  • 表单输入处理
  • 聊天应用UI调整
  • 动态布局调整
  • 滚动到聚焦字段
  • 响应式用户界面

主要特点

  • 实时键盘状态检测
  • 跨平台支持(Android 和 iOS)
  • 简单的事件监听器 API
  • 最小配置
  • 与 FocusNode 和 TextEditingController 兼容

适合对象

  • 开发表单密集型应用的开发者
  • 聊天或消息应用
  • 需要动态键盘感知布局的 UI
  • 需要响应式输入处理的应用
  • Flutter 初学者探索平台特定功能

使用建议

  • 在 Web 平台上无法使用
  • 需要妥善管理事件监听器
  • 可能需要额外的逻辑来处理复杂的UI过渡
  • 仅限键盘可见性,而非大小或动画
  • 无内置动画或过渡效果

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

keyboard_visibility

Notification service for soft-keyboard visibility

Usage

Add the dependency to your pubspec.yaml file in the root folder of your project. Look for the 'dependencies:'-line and add the following line after this line:

keyboard_visibility: any

or

keyboard_visibility: ^[CURRENT VERSION NUMBER]

(Please note that the two spaces in the beginning of the line are important) Run 'flutter packages get' in your root folder after saving the pubspec.yaml file. For additional documentation about the pubspec.yaml file please refer to the official flutter documentation using packages

Import package:keyboard_visibility/keyboard_visibility.dart, instantiate KeyboardVisibilityNotification and use the Android and iOS notifications to get events about changes of the visibility of the soft-keyboard

The best practice to call the addNewListener function is inside the initState function as in the following example:

import 'package:keyboard_visibility/keyboard_visibility.dart';

@protected
void initState() {
  super.initState();

  KeyboardVisibilityNotification().addNewListener(
    onChange: (bool visible) {
      print(visible);
    },
  );
}

Also check out the example included with the package

Getting Started

For help getting started with Flutter, view the following online documentation.

所属分类

源码仓库

使用此插件的项目