Skip to content

InteractiveViewer with a changing screen size - #60532

Merged
fluttergithubbot merged 3 commits into
flutter:masterfrom
justinmc:iv-screen-resize
Jul 2, 2020
Merged

fluttergithubbot merged 3 commits into
flutter:masterfrom
justinmc:iv-screen-resize

Conversation

@justinmc

@justinmc justinmc commented Jun 29, 2020 •

Copy link
Copy Markdown
Contributor

Description

Previously, InteractiveViewer could get into weird states when the size of the screen changed. This PR improves this behavior by preventing the caching of boundary calculations when the size of the child has changed.

CC @not-holar

Related Issues

Mentioned in #56409 (comment)

Tests

I added the following tests:

  • Change the size of the screen and expect the correct panning behavior.

Breaking Change

None

@justinmc
justinmc requested a review from LongCatIsLooong June 29, 2020 17:25
@justinmc justinmc self-assigned this Jun 29, 2020
@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Jun 29, 2020
final RenderBox childRenderBox = _childKey.currentContext.findRenderObject() as RenderBox;
final Size childSize = childRenderBox.size;
_boundaryRectCached = widget.boundaryMargin.inflateRect(Offset.zero & childSize);
if (childRenderBox.size == _childSize && _boundaryRectCached != null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: at this point the caching does seem to be worth doing anymore? You need to find the child's render box in order to verify the cache is still valid. It's only avoiding redoing the inflateRect calculation which seems cheap.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call. I removed the caching. I'm assuming findRenderObject shouldn't be too much of a performance hit, but I'll watch out for slowdown.

@fluttergithubbot
fluttergithubbot merged commit 84fc52e into flutter:master Jul 2, 2020
@justinmc
justinmc deleted the iv-screen-resize branch July 6, 2020 15:57
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants