Skip to content
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

Control paint order / z-order of slivers #164818

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

gnprice
Copy link
Member

@gnprice gnprice commented Mar 7, 2025

Fixes #145592.

When slivers in a CustomScrollView overlap, this makes it possible to control which of the slivers will sit in front of the other one, meaning that it paints last and gets hit-tested first.

In this version there are two choices: the first sliver paints in front, or the last sliver paints in front. The first sliver in front is the default; it's the behavior needed for SliverAppBar, or other situations where the first sliver is some sort of header.

The existing behavior is actually quite a bit more complicated than that, with the "center" sliver painting in front, plus it varies depending on shrinkWrap. As far as I can tell this behavior isn't documented anywhere. It's equivalent to first-sliver-in-front whenever CustomScrollView.center isn't being used; and in fact there don't seem to be any tests in the tree that notice the difference between the existing behavior and first-sliver-in-front.

So although I actually have an implementation that preserves the more complex existing defaults, I'm hopeful we won't need it: if neither google3 nor customer tests are relying on that undocumented distinction either, then we can go ahead and simplify this behavior without a breaking change.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@gnprice
Copy link
Member Author

gnprice commented Mar 7, 2025

This is a fresh copy of #163511, in hopes of getting the infra for running Google tests on PRs to successfully run this one; see #163511 (comment) .

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

LGTM from #163511 (and triggers Google testing) 🤞

@gnprice
Copy link
Member Author

gnprice commented Mar 7, 2025

Well:

[Fri, 07 Mar 2025 21:33:56 UTC] Pull request has been added to the roll queue

[Fri, 07 Mar 2025 21:39:04 UTC] An infra error occurred while running Google testing

(That's the info that's provided on the GitHub check. I appreciate that it does give that information.)

@Piinks
Copy link
Contributor

Piinks commented Mar 7, 2025

Yes, can confirm now, this is an issue not specific to this PR and is currently being worked on. Thanks for your patience @gnprice!

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Mar 7, 2025
@Piinks
Copy link
Contributor

Piinks commented Mar 11, 2025

I think this is resolved now, rebasing to give it another go!

@Piinks Piinks force-pushed the pr-sliver-order-2 branch from 09e5816 to e252330 Compare March 11, 2025 22:29
@justinmc
Copy link
Contributor

@Piinks Google testing is marked as failed here but the CL seemed to have no failures on it? Maybe I'm reading something wrong.

@Piinks
Copy link
Contributor

Piinks commented Mar 19, 2025

Yes, the Google testing shard has been going experiencing multiple infrastructure issues. This did have a failure before that I was not able to investigate before the cl was deleted, which I understand is pretty frustrating. Rebasing again to see if we can get a clean run now.

gnprice added 7 commits March 19, 2025 16:25
Instead of the legacy behavior where the center sliver paints on top,
just have the first sliver paint on top.  This is quite a bit simpler
to document and simpler to implement, and it removes variation
between a shrink-wrapped and non-shrink-wrapped viewport.

Moreover the new behavior is the same as the old whenever not using
the `center` field; and it turns out there are no tests in the tree
that notice the difference.  So hopefully this won't even be a
breaking change.
Held back for this last commit to avoid writing two versions of the
tests.  Hopefully we can go ahead with this cleaned-up behavior; if
we end up needing the legacy behavior after all, the tests can be
adapted to test that too.
I took these out as a last-minute simplifying change... and I guess
I must not have actually rerun the tests after doing so, oops.
Turns out I put them there in the first place for a good reason.
This keeps things a bit cleaner for code that uses this feature.
@Piinks Piinks force-pushed the pr-sliver-order-2 branch from e252330 to 3ff7d01 Compare March 19, 2025 21:25
@Piinks
Copy link
Contributor

Piinks commented Mar 19, 2025

If we aren't able to resolve it this time, I recommend rolling back to the non-breaking commit. Then we can consider pursuing the additional change after as a separate change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add feature to change layout order of slivers
3 participants