Allow PointerEnterEvent and PointerExitEvents to be created from any PointerEvent#28602
Conversation
…PointerEvent Avoids an implicit downcast + crash in MouseTracker, since the last pointer event can be a Move or Down event, in addition to Hover.
|
/cc @gspencergoog Can you review this? |
gspencergoog
left a comment
There was a problem hiding this comment.
Thanks for fixing this! It's unfortunate that I didn't see this when I added multiple pointer support, I would have fixed the name too. I don't think it's worth making a breaking change at this point, although I know that there are likely zero usages of that constructor in the wild.
You might add a test in mouse_tracking_test.dart that checks that mouse enter/exit works with mouse move events too. That will exercise this code, as well as the mouse tracking code.
|
Actually, in discussing it more, we think it would be best to make the breaking change and call it To do this, make a copy of your changed version of the constructor and mark the We'll need to make an announcement to the mailing list before committing, but I can do that. |
|
The test is going to be a bit more involved, unfortunately. |
|
Hmm. I wonder if the line before that should be: if (hitAnnotation.annotation?.onHover != null && lastEvent is PointerHoverEvent) {in any case. Move and Down events shouldn't be sent to |
|
Added a test |
|
I'll land this as soon as the tree is green. |
|
Actually, because of the deprecations, we need to follow the "breaking change" protocols, so I'll send an announcement and we'll wait a bit for comments. |

Description
When testing mouse hover support in a custom embedder, I noticed crashes in MouseTracker due to an implicit downcast from PointerEvent to PointerHoverEvent. The
_lastMouseEventmap can contain PointerMoveEvents and PointerDownEvents, in addition to PointerHoverEvents, so changing the type of event handled by PointerEnter/ExitEvent.fromHoverEvent seems like the best course of action. Renaming the constructor would be a breaking change however.Should I include tests for converting other pointer events into PointerEnter/ExitEvents?
Related Issues
#29696
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?