Breaking change: MouseTrackerAnnotation requires parameter "key"#3468
Breaking change: MouseTrackerAnnotation requires parameter "key"#3468
Conversation
src/docs/release/breaking-changes/mousetrackerannotation-requires-parameter-key.md
Outdated
Show resolved
Hide resolved
src/docs/release/breaking-changes/mousetrackerannotation-requires-parameter-key.md
Outdated
Show resolved
Hide resolved
src/docs/release/breaking-changes/mousetrackerannotation-requires-parameter-key.md
Outdated
Show resolved
Hide resolved
src/docs/release/breaking-changes/mousetrackerannotation-requires-parameter-key.md
Outdated
Show resolved
Hide resolved
| void detach() { | ||
| - RendererBinding.instance.mouseTracker.detachAnnotation(_hoverAnnotation); | ||
| + RendererBinding.instance.mouseTracker.detachAnnotation(_hoverAnnotation.key); | ||
| super.detach(); |
There was a problem hiding this comment.
why does the render object do this instead of the layer tree? seems weird that you have to independently tell the layer tree and the mouse tracker about the annotations.
There was a problem hiding this comment.
There are multiple reasons:
- Annotation attachment is used to indicate widget presence. Generally, an annotation should be detached if the owner widget is unmounted, for the reason described in Improve MouseTracker lifecycle: Move checks to post-frame flutter#44631 "The change to onExit". Therefore I think it's better to handle it in the render object (or should it be the element?).
- Historical reason. Attaching and detaching annotations used to have immediate effects (triggering callbacks) and we had to do it during Element.activate and deactivate. This was no longer needed, so now we only need to do it in attach and detach, but we haven't fully moved it to layers yet.
- Future plan. We're planning to experiment a change that split annotations from the layer tree to fix issues such as Poor performance when subscribing to MouseRegion events flutter#41194. Therefore we'd like to keep it separated from the layer tree (at least for now).
There was a problem hiding this comment.
It'll still have to be in the layer tree though right? Just done differently than today (many nodes dealing with one layer rather than one layer per node).
This just seems like an unnecessarily awkward API right now.
Anyway, the point of my questions is that you should explain this in the breaking change document. Especially if we're planning on changing this again, we should warn people that we're not done changing this API.
dkwingsmt
left a comment
There was a problem hiding this comment.
Fixed review comments, with one comment replied.
|
Closing this because I found out that it's probably neither necessary nor sufficient. I've also closed the corresponding Flutter PR in favor of flutter/flutter#48453. |
Breaking change documentation for PR flutter/flutter#46034.
Design doc: https://flutter.dev/go/key-based-mouse-tracker-annotation