Skip to content
pubscout

transparent_pointer

1.0.1, released 3 years ago by spkersten.nl

A widget that makes itself transparent to hit testing while letting its subtree receive pointer events.

WASM-ready
$ flutter pub add transparent_pointer
Source repository

What it does

TransparentPointer allows you to control hit testing so that a widget is invisible to pointer events for its parent, yet still allows its own subtree to receive them. This enables overlapping widgets to simultaneously capture gestures.

AI-written summary of version 1.0.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need a gesture detector behind another widget to still receive drag or tap events.
  • You want a widget to pass hit tests to its parent while its child remains interactive.

Skip it when

  • Standard Stack and IgnorePointer or AbsorbPointer behaviors already meet your interaction needs.

Strengths

  • Solves complex overlapping gesture routing problems easily.
  • Lightweight with no extra native dependencies.

Weaknesses

  • Can make gesture debugging harder due to non-standard hit test behavior.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
Stack(
  children: [
    GestureDetector(
      behavior: HitTestBehavior.opaque,
      onVerticalDragStart: (_) => print("Background drag started"),
    ),
    TransparentPointer(
      child: TextButton(
        child: Text("Tap me"),
        onPressed: () => print("You tapped me"),
      ),
    ),
  ],
)

Alternatives

Packages that do the same job and could replace transparent_pointer.

  • hit

    Decouple Flutter layout size from hit-test size to deliver taps outside parent bounds.