Skip to content

InteractiveViewer should call onInteractionUpdate even when gesture is disabled #78990

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

Merged

Conversation

justinmc
Copy link
Contributor

InteractiveViewer provides onInteractionStart/Update/End events so that users can get information about gestures happening on the child without running into problems with overlapping GestureDetectors. This information should be provided even when the gesture is disabled, and it is documented as such. However, onInteractionUpdate wasn't being called. This PR fixes it.

Closes #77455

@justinmc justinmc self-assigned this Mar 24, 2021
@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Mar 24, 2021
@google-cla google-cla bot added the cla: yes label Mar 24, 2021
@@ -781,6 +781,12 @@ class _InteractiveViewerState extends State<InteractiveViewer> with TickerProvid
// Handle an update to an ongoing gesture. All of pan, scale, and rotate are
// handled with GestureDetector's scale gesture.
void _onScaleUpdate(ScaleUpdateDetails details) {
widget.onInteractionUpdate?.call(ScaleUpdateDetails(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason a new ScaleUpdateDetails has to be constructed instead of just passing details to the callback?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation states:

At the time this is called, the TransformationController will have already been updated to reflect the change caused by the interaction.

Is the statement still true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About ScaleUpdateDetails: The reason was that I didn't want to pass things that weren't being applied, like independent vertical and horizontal scales. However, given that I call this even when all interaction is disabled, I think you're right and I should just pass everything.

About the docs: You're right, thanks for catching that. I think I should actually keep the behavior as it is documented. I'll move my calls to onInteractionUpdate.

@fluttergithubbot fluttergithubbot merged commit 4982a7f into flutter:master Mar 31, 2021
@justinmc justinmc deleted the iv-interaction-update-when-disabled branch March 31, 2021 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InteractiveViewer onInteractionUpdate does not get called when panEnabled is false.
3 participants