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

avoid_keyboard 封面
插件详情v0.3.0

avoid_keyboard

此包可实现便捷的键盘避让。它可用于为特定视图区域启用键盘避让,而无需压缩整个视图。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1150
喜欢数
26
Pub 分数
150

安装插件

flutter pub add avoid_keyboard

插件介绍

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

avoid_keyboard 包为 Flutter 应用提供了一种简单的方法来管理键盘避让,允许特定的视图区域在键盘出现时进行调整。与全屏调整不同,它避免了压缩整个 UI,从而保持布局完整性。该包可在 Android、iOS、Web、macOS、Windows 和 Linux 等多个平台上使用。对于表单或输入密集型界面,该包非常适合,因为在用户交互过程中保持视觉上下文至关重要。

适合场景

  • 表单输入项具有动态布局调整
  • 带有消息输入字段的聊天界面
  • 自定义可滚动区域,避免键盘重叠
  • 需要精确键盘处理的移动优先用户界面
  • 带有响应式输入区域的网页和桌面应用程序

主要特点

  • 区域特定的键盘避让
  • 无完整视图压缩
  • 跨平台支持
  • 使用 widget 包装器的最小设置
  • 支持可滚动容器
  • 与现有的滚动视图兼容

适合对象

  • 开发输入密集型应用的开发者
  • 面向多个平台的团队
  • 需要精细控制的UI设计师
  • 具有复杂表单布局的应用程序
  • 需要流畅键盘交互的项目

使用建议

  • 复杂布局可能需要手动定位逻辑
  • 不适用于全屏键盘避让
  • 对高频更新的性能影响
  • 超出基本偏移之外的自定义功能有限
  • 需要在所有目标平台上进行仔细测试

原始 README

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

avoid_keyboard

pub version pub points likes popularity

The avoid_keyboard package includes a widget (AvoidKeyboard) in which you can wrap your text fields and other input controls, such that they will scroll out of the way when the keyboard pops up. Using this widget has an advantage over using the default Scaffold behavior, in that you can specify exactly which areas of your app will scroll in response to the keyboard, rather than having your entire viewport compressed (which won't work anyway for fixed height columns).

Another advantage, is that AvoidKeyboard will only shift its contents in the case that the keyboard is actually overlapping the focused input control.

demonstration gif

Getting Started

To get started, simply wrap the input controls (along with any surrounding portion of the widget tree which should move out of the way):

class AvoidKeyboardExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AvoidKeyboard(
      child: Column(
        children: [
          TextField(),
          TextField(),
        ],
      ),
    );
  }
}

Having done this, the view will now scroll out of the way when the keyboard overlaps an active control.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。