搜尋套件、儲存庫與 APP 分類

套件詳情v2.0.4

keyboard_service

鍵盤可見性/(自動)隱藏套件,無需原生外掛

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1080
喜歡數
43
Pub 分數
160

安裝套件

flutter pub add keyboard_service

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,可在多個平台管理鍵盤可見性與自動關閉,無需使用原生外掛。它提供簡單、跨平台的解決方案,用於偵測鍵盤是否開啟或關閉,並允許開發者程式化隱藏鍵盤。適合用於表單和輸入密集型介面,以提升使用者體驗,確保順暢的鍵盤互動。此套件可在 Android、iOS、Web、macOS、Windows 和 Linux 上順暢運作,是現代 Flutter 應用的多功能選擇。

適用情境

  • 表單輸入處理
  • 焦點變更時自動關閉鍵盤
  • 改善聊天應用的使用者體驗
  • 處理UI中的鍵盤重疊問題
  • 響應式版面調整
  • 動態表單欄位管理

主要特色

  • 跨平台相容性
  • 無需原生外掛程式
  • 鍵盤狀態檢測
  • 程式化鍵盤隱藏
  • 輕量且易於整合
  • 支援所有主要的桌面與行動平台

適合對象

  • 開發跨平台應用的開發者
  • 包含複雜輸入表單的應用程式
  • 聊天或訊息介面
  • 需要響應式鍵盤處理的 UI
  • 團隊避免平台特定程式碼

使用建議

  • 可能不支援網頁上的所有邊緣情況
  • 鍵盤行為的自訂功能有限
  • 依賴於 Flutter 的內建鍵盤 API
  • 不適合進階鍵盤自訂
  • 在嵌套滾動視圖中需要謹慎處理

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

keyboard_service

Keyboard visibility / (auto-) dismiss package without the need of native plugin

Watch on GitHub Star on GitHub pub package

Getting Started

Use it for example when you want to automatically dimiss the on-screen keyboard when tapped outside of textfield. And if you want know if the on-screen keyboard is visible and/or want to explicitly dismiss it.

There are 2 classes

  • 'KeyboardService': Check if keyboard is visible and dismiss keyboard.
  • 'KeyboardAutoDismiss': A widget that wraps a Scaffold widget for automatically dismissing the keyboard.

Also see example project

Wrap your top scaffold:

return KeyboardAutoDismiss(
        scaffold: Scaffold(
            appBar: AppBar(
                title: Text('Keyboard Service Example'),
            ),
      ...
        ),
    );

Use the service class if needed:

// Use method below to dismiss the keyboard
KeyboardService.dismiss();

// Use the optional BuildContext parameter to remove focus of a TextField
KeyboardService.dismiss(unfocus: context);

// Check if the keyboard is visible
KeyboardService.isVisible(context);

License

This project is licensed under the MIT License - see the license file for details.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。