-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix nested listeners so that ancestor listeners can also receive enter/exit/move events. #32350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
82f1acd to
434f912
Compare
434f912 to
0e765eb
Compare
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nitt
| } | ||
|
|
||
| @override | ||
| Iterable<S> findAll<S>(Offset regionOffset) sync* { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I really dislike sync*, it has very poor performance characteristics. On the other hand, it is a clear win getting to implement findAll in terms of find in a lazy manner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this was a tradeoff. It's an implementation detail, though, so we can change it to use lists or something if it turns out to hurt performance.
…ive enter/exit/move events. (flutter#32350)" This reverts commit aeccd6a due to a performance regression.
Description
This changes
Listenerto trigger enter/move/exit in allListeners below the pointer, not just the leaf region (the first region hit). This is because we need to allow listeners to be nested so that, say, a widget that handles changing color on hover, but also is wrapped in aTooltip(that handles hover) can trigger both actions, not just one.To that end, I added a
findAlltoLayer, similar to the existingfindmethod that was previously used. It returns an iterator over annotated layers which match the given data type.Since the
findAllis implemented as returning an Iterable (and issync*), I re-implemented thefindroutines as just returning the first result fromfindAll, since that should be just as efficient, and would then prevent duplication in the implementation.Tests
I added the following tests:
findAllsimilar tofind, as well as extra tests having to do with returned order of results (which is leaf first, then ancestors).Listenerthat assure that nested listeners do the right thing.Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?