Skip to content

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Oct 9, 2020

This relands #65226, which was reverted in #66918 because it caused regressions in google3 for tests involving page views that used ensureVisible.

A test was added in #67021 which covers it.

The changes between this and the original change are in b840a8a, which does the following:

  • Minor optimization to avoid calculating a rect when targetRenderObject == renderObject
  • Override ensureVisible in _PagePosition to discard the targetRendreObject. As explained in the comment, this prevents further attempts to "center" the target render object, which could result in changing which page is used.

@xu-baolin

Fixes #65100

@google-cla google-cla bot added the cla: yes label Oct 9, 2020
@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Oct 9, 2020
Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

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

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

/// The optional `targetRenderObject` parameter is used to determine which area
/// of that object should be as visible as possible. If `targetRenderObject` is null,
/// the entire [RenderObject] (as defined by its [RenderObject.paintBounds])
/// will be as visible as possible. If `targetRenderObject` is provided it should be
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// will be as visible as possible. If `targetRenderObject` is provided it should be
/// will be as visible as possible. If `targetRenderObject` is provided, it should be

Also should be? Or must? It would be nice to enforce that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing to must.


Rect? targetRect;
if (targetRenderObject != null && targetRenderObject != object) {
targetRect = MatrixUtils.transformRect(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to add an assert to make sure that targetRenderObject is a descendant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

getTransformTo asserts it.

@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@dnfield
Copy link
Contributor Author

dnfield commented Oct 10, 2020

Internal failure appears to be a flake. Looking into it.

@dnfield
Copy link
Contributor Author

dnfield commented Oct 10, 2020

Yup, flake.

@dnfield dnfield merged commit 8bb61c3 into flutter:master Oct 10, 2020
@dnfield dnfield deleted the reland_ensure_vis branch October 10, 2020 00:40
@xu-baolin
Copy link
Member

Does _TabBarScrollPosition need to override the ensureVisible function?

@dnfield
Copy link
Contributor Author

dnfield commented Oct 10, 2020

Hmm. Probably. It might be ok because tabview uses pageview under the hood. Will have to check.

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.

Scrollable.ensureVisible does not work with nested SingleChildScrollViews on both axes

4 participants