Skip to content

refactor: Make GestureDetectorBuilder and detector/callback registering more resilient#3900

Merged
luanpotter merged 4 commits intomainfrom
luan.recognizers
Apr 27, 2026
Merged

refactor: Make GestureDetectorBuilder and detector/callback registering more resilient#3900
luanpotter merged 4 commits intomainfrom
luan.recognizers

Conversation

@luanpotter
Copy link
Copy Markdown
Member

@luanpotter luanpotter commented Apr 13, 2026

Description

Make GestureDetectorBuilder and detector/callback registering more resilient wrt to multiple registrations (callbacks that use the same detector).

This extracts a base class to dispatchers to share code and remove reundancies.
It also makes the code on *Callbacks themselves trivial, and accounts for duplication.
Before different callbacks could duplicate dispatchers. Now we properly guarantee dispatchers are singleton while allowing callbacks to require and use the same dispatcher. This is important for tertiary callbacks which will use the same underlying dispatcher as secondary.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

@luanpotter luanpotter force-pushed the luan.recognizers branch 2 times, most recently from 26b9a08 to f46ad2e Compare April 19, 2026 15:58
Comment thread packages/flame/lib/src/game/flame_game.dart Outdated
T Function() constructor,
void Function(T) initializer,
) {
final count = _counters[T];
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we just have one dispatcher per gesture now, and it can be much better tracked on a single map

@luanpotter luanpotter marked this pull request as ready for review April 25, 2026 21:06
@luanpotter luanpotter requested a review from spydon April 25, 2026 21:06
Copy link
Copy Markdown
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

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

Good stuff!

@luanpotter luanpotter merged commit 84b77a0 into main Apr 27, 2026
8 checks passed
@luanpotter luanpotter deleted the luan.recognizers branch April 27, 2026 12:32
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.

2 participants