Skip to content

Conversation

@FeodorFitsner
Copy link
Contributor

@FeodorFitsner FeodorFitsner commented Jan 15, 2026

Fix #6015

Pass TapDownDetails to the 'tap' event in the Dart GestureDetector implementation and update the Python type annotation for on_tap to use EventHandler[TapEvent[GestureDetector]]. This improves event data consistency and type safety.

Summary by Sourcery

Include tap position details in GestureDetector tap events and align Python type annotations with the richer tap event data.

New Features:

  • Expose tap-down details data with the GestureDetector "tap" event payload.

Enhancements:

  • Cache tap-down details in the Dart GestureDetector control to reuse them when firing tap events.
  • Relax GestureDetector on_tap_down wiring so tap-down details are captured whenever tap or tap-down handlers are registered.
  • Update the Python GestureDetector on_tap type annotation to use EventHandler[TapEvent[GestureDetector]] for stronger typing of tap events.

Pass TapDownDetails to the 'tap' event in the Dart GestureDetector implementation and update the Python type annotation for on_tap to use EventHandler[TapEvent[GestureDetector]]. This improves event data consistency and type safety.
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 15, 2026

Deploying flet-examples with  Cloudflare Pages  Cloudflare Pages

Latest commit: e1bdb2a
Status: ✅  Deploy successful!
Preview URL: https://9d995f1a.flet-examples.pages.dev
Branch Preview URL: https://on-tap-event-coords.flet-examples.pages.dev

View logs

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds position details (local and global coordinates, device kind) to the on_tap event in the GestureDetector control. Previously, the on_tap event provided no position information, making it inconsistent with other tap events like on_tap_down and on_tap_up.

Changes:

  • Modified Dart implementation to capture and pass TapDownDetails to the tap event
  • Updated Python type annotation from ControlEventHandler to EventHandler[TapEvent["GestureDetector"]] for type consistency

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
sdk/python/packages/flet/src/flet/controls/core/gesture_detector.py Updated type annotation for on_tap to use TapEvent type for improved type safety
packages/flet/lib/src/controls/gesture_detector.dart Added state variable to store TapDownDetails and modified event handlers to capture and pass position data to tap event

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Replaces bitwise OR '|' with logical OR '||' in the onTapDown condition to ensure correct evaluation of gesture callbacks.
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 15, 2026

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: e1bdb2a
Status:⚡️  Build in progress...

View logs

Deleted packages/flet/CHANGELOG.md and updated the main CHANGELOG.md. Updated the README and pubspec.yaml in packages/flet to reflect these changes.
Copy link
Contributor

@ndonkoHenri ndonkoHenri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - let me have your thoughts on changelog comment

Removed the symlink to ../../CHANGELOG.md in packages/flet/CHANGELOG.md and replaced it with a full copy of the changelog content. This change ensures the changelog is directly available within the package directory.
@FeodorFitsner FeodorFitsner merged commit 9839c19 into main Jan 16, 2026
13 of 30 checks passed
@FeodorFitsner FeodorFitsner deleted the on-tap-event-coords branch January 16, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TapEvent missing coordinate attributes and e.data is empty/invalid in Flet 0.80+ (Flutter 3.38)

3 participants