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

套件詳情v1.0.1

transparent_pointer

提供 TransparentPointer 以控制命中測試

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.6萬
喜歡數
59
Pub 分數
150

安裝套件

flutter pub add transparent_pointer

套件介紹

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

transparent_pointer 套件提供了一個稱為 TransparentPointer 的組件,讓開發者可以在 Flutter 應用中控制命中測試。透過將組件包裝在此元件中,您可以使其對指針事件透明,進而讓底層組件接收觸控或滑鼠輸入。這在測試期間或建構複雜 UI 時特別有用,尤其是在需要精確事件處理的情況下。該套件支援所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。

適用情境

  • 測試 UI 互動
  • 跳過疊加層的命中測試
  • 建立層級化使用者介面元件
  • 調試手勢衝突
  • 實現透明觸控區域
  • 在測試中模擬使用者輸入

主要特色

  • 控制命中測試行為
  • 支援所有 Flutter 平台
  • 簡單的 widget 包裝器
  • 適用於測試情境
  • 啟用事件委派
  • 輕量且簡潔

適合對象

  • 測試自動化工程師
  • 需要細粒度控制的UI開發人員
  • Flutter 應用測試人員
  • 開發互動式覆蓋層的開發者
  • 那些調試手勢問題的開發者
  • 原型化複雜的手勢流程

使用建議

  • 不適用於生產環境的使用者介面
  • 可能會干擾正常的觸控行為
  • 在複雜版面中需要仔細整合
  • 限制為命中測試操作
  • 最適合在開發或測試環境中使用
  • 不會影響視覺渲染

原始 README

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

transparent_pointer

TransparentPointer is a widget that is invisible for its parent to hit testing, but still allows its subtree to receive pointer events. This is useful to allow a gesture detector that is visually behind another widget to still receive pointer events, while at the same time allowing that other widget to receive those events as well.

Example

In this example, a drag can be started anywhere in the widget, including on top of the text button, even though the button is visually in front of the background gesture detector. At the same time, the button is tappable.

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        GestureDetector(
          behavior: HitTestBehavior.opaque,
          onVerticalDragStart: (_) => print("Background drag started"),
        ),
        Positioned(
          top: 60,
          left: 60,
          height: 60,
          width: 60,
          child: TransparentPointer(
            child: TextButton(
              child: Text("Tap me"),
              onPressed: () => print("You tapped me"),
            ),
          ),
        ),
      ],
    );
  }
}

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。