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

flutter_keyboard_size 封面
插件详情v1.0.1

flutter_keyboard_size

一个简单方便的提供者,可帮助获取以下信息 - 键盘高度、键盘是否打开、设置屏幕是否较小的布尔值。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2万
喜欢数
67
Pub 分数
160

安装插件

flutter pub add flutter_keyboard_size

插件介绍

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

flutter_keyboard_size 是一个轻量级的 Flutter 包,可提供关于屏幕键盘的实时信息,包括其高度以及是否已打开。它还能帮助判断屏幕尺寸是否较小,对响应式 UI 调整非常有用。该包提供基于 provider 的简单 API,可在多个平台上访问键盘状态和尺寸,确保在 Android、iOS、Web、macOS、Windows 和 Linux 上行为一致。非常适合需要在键盘出现或消失时动态调整布局的应用。

适合场景

  • 调整键盘打开时的UI布局
  • 检测表单中的键盘可见性
  • 适用于小屏幕的响应式设计
  • 处理输入字段定位
  • 基于键盘高度的动态填充

主要特点

  • 实时键盘高度检测
  • 键盘打开/关闭状态监控
  • 屏幕尺寸分类
  • 基于 Provider 的状态管理
  • 跨平台支持
  • 简单的 API 集成

适合对象

  • 表单密集型应用
  • 聊天或消息界面
  • 以移动设备为优先的用户界面
  • 响应式布局
  • 需要动态输入处理的应用程序

使用建议

  • 可能需要在状态更改时重新构建
  • 仅限与键盘相关的指标
  • 不适合复杂手势检测
  • 依赖于平台特定的键盘事件
  • 最好与状态管理(如 Provider)一起使用

原始 README

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

flutter_keyboard_size Pub

When the virtual keyboard is opened, we can get its height with MediaQuery.of(context).viewInsets.bottom

BUT, in case of complicated widgets tree, it doesn't work. So, every time we have to mutate the keyboard size down to the widget tree.

This package is a straightforward and convenient provider that helps get info about: keyboard height, is it open or not, set bool value is screen small or not.

Showcase|100x100, 10%

Usage

After installing wrap Scaffold widget to

KeyboardSizeProvider(
      smallSize: 500.0,
      child: Scaffold(

where smallSize property is optional, default is 400.0

After that, down to the widget tree you can use Consumer widget to get info about keyboard

Widget build(BuildContext context) {
    return Consumer<ScreenHeight>(
      builder: (context, _res, child) {
        return Center(

available properties:

  double keyboardHeight
  double screenHeight
  bool isSmall // returns true if screen height becomes less then smallSize property
  bool isOpen // true if open

Full example is here https://github.com/awaik/flutter_keyboard_size/tree/master/example

Credits

This is a project by Agoradesk, P2P cryptocurrency trading platform. Created by the team behind LocalMonero, the biggest and most trusted Monero P2P trading platform.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目