-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Split Mouse from Listener #36217
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
Split Mouse from Listener #36217
Conversation
dev/automated_tests/flutter_test/print_user_created_ancestor_expectation.txt
Outdated
Show resolved
Hide resolved
dev/automated_tests/flutter_test/print_user_created_ancestor_no_flag_expectation.txt
Outdated
Show resolved
Hide resolved
| onPointerExit: (PointerExitEvent event) => _hideTooltip(), | ||
| result = MouseRegion( | ||
| onEnter: (PointerEnterEvent event) => _showTooltip(), | ||
| onExit: (PointerExitEvent event) => _hideTooltip(), |
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.
why do we use methods in the previous two files and closures here? we should be consistent.
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.
I agree, but I'm leaning towards making as few changes in other files as possible since it's a breaking PR.
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.
not sure why it being a breaking PR matters here?
But if you want to change it in another PR that's fine. :-)
| if (listeners.isEmpty) | ||
| listeners.add('<none>'); | ||
| properties.add(IterableProperty<String>('listeners', listeners)); | ||
| // TODO(jacobr): add raw listeners to the diagnostics data. |
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.
@jacob314 Is there anything special we need to do to resolve this TODO?
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.
properties.add(ObjectFlagProperty<PointerDownEventListener>('onPointerDown', onPointerDown, ifPresent: 'down', level: DiagnosticLevel.fine);Would be an idiomatic way to expose each of these.
That would hide the output from the default display but let the inspector provide links to the actual listeners used.
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.
@jacob314
The current way allows a clean format with the help of IterableProperty,
'listeners: down, move, up, cancel, signal'
or
'listeners: <none>'
Is there a way to maintain the current format while using ObjectFlagProperty?
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.
Not currently. Are there any cases with a subclass that wants to add an additional listener? In that case it could make sense to come up with a scheme that enables defining each listener as an ObjectFlagProperty and then aggregate the properties into a terse summary like listeners: down, move, up, cancel when generating the string output.
| set onPointerEnter(PointerEnterEventListener value) { | ||
| if (_onPointerEnter != value) { | ||
| _onPointerEnter = value; | ||
| PointerEnterEventListener get onEnter => _onEnter; |
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.
It's too bad we can't now name these MouseEnterEventListener, etc., but I do understand: that would make it a larger breaking change.
chunhtai
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
This is a leftover change from flutter#36217 (comment)
Description
This PR introduces a few breaking changes in order to split the mouse tracking callbacks from
Listener. More specifically,onPointer{Enter,Hover,Exit}out fromListener, into a new class,MouseRegion.onPointer{Enter,Hover,Exit}out fromRenderPointerListener, into a new class,RenderMouseRegion.onPointer{Enter,Exit,Hover}intoon{Enter,Exit,Hover}.In order to keep compatibility,
Listenerwill keeponPointer{Enter,Hover,Exit}but mark them as deprecated. They will be removed after the next stable.For reasoning, impact, and discussion, see #36085
Regarding test change
This PR broke some tests, namely "report which user created widget caused the error" and its variant, in a weird way. It changed the widget in which an error was built, hence changing the error description from
into
which seems like a side effect of splitting
RenderMouseListenerout, and should be harmless.Since these lines are not the target lines of the aforementioned tests, I decided to tell the tests to skip checking these lines. This change has been discussed with and approved by @chunhtai .
Related Issues
Tests
I added the following tests:
Replace this with a list of the tests that you added as part of this PR. A change in behaviour with no test covering it
will likely get reverted accidentally sooner or later. PRs must include tests for all changed/updated/fixed behaviors. See Test Coverage.
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?