搜索插件、代码仓与 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"),
            ),
          ),
        ),
      ],
    );
  }
}

所属分类

源码仓库

使用此插件的项目

暂无相关数据。