搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案