Skip to content

SliverAppBar with ShrinkWrap Patch#73195

Merged
fluttergithubbot merged 3 commits intoflutter:masterfrom
NWalker1208:shrinkwrap-patch
Jan 7, 2021
Merged

SliverAppBar with ShrinkWrap Patch#73195
fluttergithubbot merged 3 commits intoflutter:masterfrom
NWalker1208:shrinkwrap-patch

Conversation

@NWalker1208
Copy link
Contributor

@NWalker1208 NWalker1208 commented Jan 1, 2021

This better emulates the behavior of the standard Viewport class, which, after painting all children before its center child, paints its center child and all subsequent children in reverse order. This fixes a bug causing children of a shrink-wrapping CustomScrollView to paint over a SliverAppBar.

Description

This PR simply reverses childrenInPaintOrder for the RenderShrinkWrappingViewport class. This solves any issues where slivers in a CustomScrollView would paint over a SliverAppBar whenever the scroll view had shrink-wrapping enabled.

Related Issues

#28197 Resolved by this PR.
#36002 Partly resolved by this PR. I did not modify scrolling behavior.
#52976 Partly resolved by this PR.

Tests

I added the following tests:

  • "Viewport childrenInPaintOrder control test" (rendering/viewport_test.dart)
    • Tests both RenderViewport and RenderShrinkWrappingViewport.
    • Checks if childrenInPaintOrder is in reverse order of a list of three children.
      • Does NOT test how specifying a center child modifies that order.
    • Checks if childrenInPaintOrder is in reverse order of childrenInHitTestOrder.
      • This rule is specified in the documentation of RenderViewportBase.

Checklist

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.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.

This better emulates the behavior of the standard viewport, which paints its center child and all subsequent children in reverse order. It also fixes a bug causing children of a shrink-wrapping CustomScrollView to paint over a SliverAppBar.
Documentation states that childrenInHitTestOrder should be the reverse of childrenInPaintOrder. Updated to match change to childrenInPaintOrder.
@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Jan 1, 2021
@google-cla google-cla bot added the cla: yes label Jan 1, 2021
@Piinks Piinks self-requested a review January 6, 2021 23:09
@Piinks Piinks added a: layout SystemChrome and Framework's Layout Issues f: scrolling Viewports, list views, slivers, etc. labels Jan 7, 2021
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.

Hey @NWalker1208 thanks for the contribution! I am going to run this through additional internal tests first to check for potential breaks.

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! Thank you @NWalker1208 for your first contribution!

@fluttergithubbot fluttergithubbot merged commit b65a235 into flutter:master Jan 7, 2021
@NWalker1208 NWalker1208 deleted the shrinkwrap-patch branch January 7, 2021 23:33
@BazinC
Copy link

BazinC commented Jan 19, 2021

Hey @Piinks! :)
Could you please give insight on the release date on stable branch for this patch ?
I need it asap on a big prod app 😳
Since the issue is in the the rendering layer, I can't just copy paste the patch 😅

@Piinks
Copy link
Contributor

Piinks commented Jan 19, 2021

Hi @BazinC I do not know the date that this change will arrive on stable.
You can read in our wiki about our release process and channels, maybe building your app on beta or dev can work in the meantime.
https://github.com/flutter/flutter/wiki/Flutter-build-release-channels

Our wiki also has some guidance on identifying where a fix is, like this one, so this may be helpful as well: https://github.com/flutter/flutter/wiki/Where%27s-my-Commit%3F

@BazinC
Copy link

BazinC commented Jan 19, 2021

Thanks for your answer @Piinks!
But we would not want to build our app on other branch than stable.
It's ok, I managed to copy/paste the code from this patch and create a PatchedCustomScrollView using it.
I don't like this kind of workaround but that's all I got for now.
👍 Hopefully Flutter is an open source framework
👎 Fortunately Flutter code has migrated to null-safety, so it is no longer easy to copy/paste code in a non-null-safety project😅
I hope the fix will be released asap :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: layout SystemChrome and Framework's Layout Issues 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.

4 participants