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

所屬分類

原始碼儲存庫

使用此套件的專案