-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Move declaration of semantic handlers from detectors to recognizers #33475
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
| import 'drag_details.dart'; | ||
|
|
||
| /// Called when the user taps with a semantics device. | ||
| typedef SemanticsTapCallback = void Function(); |
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.
So, will something that is declared as a GestureTapCallback be passed to these functions that take a SemanticsTapCallback? If so, then I worry a bit that if we modify GestureTapCallback, then we'd have to know to also change this signature.
Probably not a big deal, since the compiler will complain a lot if that happens, but you might want to put some non-doc comments here about keeping them in sync.
If this is just renaming the type of arguments here (as it looks like it might be), then this is fine.
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.
So, will something that is declared as a GestureTapCallback be passed to these functions that take a SemanticsTapCallback?
Yes.
The idea is that information passed by a semantic event might be different from that passed by a pointer event, therefore it makes sense for them to diverge. Actually I was about to change this callback to include a SemanticsTapDetails, but didn't because that will be a breaking change for RenderSemanticsGestureHandler. I think when it happens (which will be a breaking change anyway) we should not keep them in sync.
Description
Currently the work of dispatching semantic events to recognizer callbacks is done by
RawGestureDetector. The biggest drawback of this design, among others, is that the involved recognizers are hard coded, therefore custom recognizers are unable to get themselves notified on semantic events.This PR moves this work to recognizers by adding a new method to
GestureRecognzier:which returns a class that has one optional callback for each kind of semantic event. Gesture detector will collect the configuration from all of its recognizers and summarize them into one callback per kind of event, therefore becoming agnostic of actual recognizer type.
This PR also renames all callbacks related to semantics to
Semantics*Callbackfrom the currentGestureTapCallback,GestureLongPressCallback, etc. They are the same (therefore is non-breaking),but
Gesture*Callbacks are defined by subclasses ofGestureRecognizer, which are inappropriate forGestureRecognizerto know.Related Issues
Tests
I added the following tests:
{Tap,LongPress,HorizontalDrag,VerticalDrag,Pan}GestureRecognizer:RawGestureDetectorChecklist
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?