Sitelet https://github.com/flutter/flutter/pull/191329
Skip to content

Use leading scroll offset instead of infinite offset to reveal pinned slivers - #191329

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
victorsanni:sliver-persistent-header-visible
Aug 28, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
victorsanni:sliver-persistent-header-visible

Conversation

@victorsanni

@victorsanni victorsanni commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Applicable only if the target provided to RenderViewportBase.getOffsetToReveal (and its callers e.g Scrollable.ensureVisible, scrollUntilVisible etc.) is a pinned sliver.

(in say AxisDirection.down) If the pinned sliver is below the leading edge, scroll the viewport by the minimum offset required to pin the sliver rather than giving it an infinite target offset which just makes it scroll to the end of the viewport. While the header will always remain pinned, other slivers below it do not need to scroll.

Fixes When calling Scrollable.ensureVisible to pinned SliverPersistentHeader, the view scrolls too much

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 19, 2026
@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Aug 19, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates RenderViewportBase.getOffsetToReveal to calculate a specific target offset for pinned slivers instead of returning infinite offsets. It also introduces a comprehensive set of test cases in viewport_test.dart to verify the revealed offset behavior for pinned slivers across various scroll directions and growth directions. No review comments were provided, so there is no additional feedback.

@victorsanni victorsanni reopened this Aug 20, 2026
@fluttergithubbot

Copy link
Copy Markdown
Contributor

An existing Git SHA, 7061976cb9646de81713d85e98b2606acdcab420, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@victorsanni
victorsanni requested a review from Piinks August 20, 2026 21:50
@victorsanni

Copy link
Copy Markdown
Contributor Author

Looked at the Google testing failures, both seem expected.

First is a CustomScrollView with a pinned SliverAppBar and a SliverFillRemaining with hasScrollBody: false containing a column with an ExpansionTile. The test calls scrollUntilVisible on the unexpanded ExpansionTile, pinning the SliverAppBar. Then the ExpansionTile was expanded, increasing the height of the scrollable content --> increasing maxScrollExtent.

Second is more straightforward, tester.ensureVisible is called on a Tab/TabBar in a PinnedHeaderSliver. Its TabBarView is in a SliverFillRemaining with hasScrollBody: true.

In both cases, the previous image showed the SliverFillRemaining scrolled to the end, it was probably double.infinity then clamped to maxScrollExtent. This meant the target could end up being non-visible if there was enough content between it and the end of the scrollable content. In fact, one of the tests showed that, but with this PR it now only scrolls enough to reveal the target and no more, so the target is always visible.

@Piinks Piinks left a comment

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.

LGTM

@victorsanni victorsanni added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 27, 2026
@auto-submit

auto-submit Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/191329, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 27, 2026
@victorsanni
victorsanni force-pushed the sliver-persistent-header-visible branch from 7061976 to f393623 Compare August 27, 2026 21:42
@victorsanni victorsanni added CICD Run CI/CD and removed CICD Run CI/CD labels Aug 27, 2026
@victorsanni victorsanni added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 28, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Aug 28, 2026
Merged via the queue into flutter:master with commit 308f8fd Aug 28, 2026
23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 28, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Aug 28, 2026
flutter/flutter@e8dca90...8d8c1aa

2026-08-28 engine-flutter-autoroll@skia.org Roll Packages from bd3cbc1 to cd4cdd0 (15 revisions) (flutter/flutter#191965)
2026-08-28 matthiasngeo@gmail.com Bump customer testing version to pick up forui tests (flutter/flutter#191931)
2026-08-28 victorsanniay@gmail.com Use leading scroll offset instead of infinite offset to reveal pinned slivers (flutter/flutter#191329)
2026-08-28 engine-flutter-autoroll@skia.org Roll Skia from 21f71051e749 to fe0b9a5261f9 (1 revision) (flutter/flutter#191960)
2026-08-28 robert.ancell@canonical.com Share the common Linux window controller code in mixins (flutter/flutter#191930)
2026-08-28 engine-flutter-autoroll@skia.org Roll Dart SDK from 2cf2f69fd9f0 to ae63a6eca3f1 (1 revision) (flutter/flutter#191953)
2026-08-28 engine-flutter-autoroll@skia.org Roll Skia from 11e3a7cb0fd0 to 21f71051e749 (3 revisions) (flutter/flutter#191942)
2026-08-28 engine-flutter-autoroll@skia.org Roll Dart SDK from e030e77d5413 to 2cf2f69fd9f0 (2 revisions) (flutter/flutter#191934)
2026-08-28 32538273+ValentinVignal@users.noreply.github.com Remove no-shuffle in flutter tools overall experience test (flutter/flutter#191861)
2026-08-28 bkonyi@google.com [flutter_tools] Gracefully handle Windows Application Control and security policy execution blocks (flutter/flutter#191912)
2026-08-28 bkonyi@google.com [tool] Migrate ConfigCommand to modular dependency injection (flutter/flutter#190743)
2026-08-28 engine-flutter-autoroll@skia.org Roll Skia from 37459da0a755 to 11e3a7cb0fd0 (9 revisions) (flutter/flutter#191929)
2026-08-28 robert.ancell@canonical.com Connect to moved-to-rect after the window is realized (flutter/flutter#191773)
2026-08-28 chris@bracken.jp macOS: Compare accessibility strings as NSStrings in tests (flutter/flutter#191853)
2026-08-28 chris@bracken.jp macOS: Record test accessibility notifications in a dictionary (flutter/flutter#191854)
2026-08-28 engine-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from 6SXRz6wsA2Zm_rAqP... to u_fSMsPU22VvUsvSo... (flutter/flutter#191927)
2026-08-28 engine-flutter-autoroll@skia.org Roll Dart SDK from cb4c39d067f3 to e030e77d5413 (3 revisions) (flutter/flutter#191923)
2026-08-27 okorohelijah@google.com Migrate ios driver tests batch 2 to simulators (flutter/flutter#190930)
2026-08-27 bkonyi@google.com [flutter_test] Ensure LiveTestWidgetsFlutterBinding executes frame and pointer callbacks in the test zone (flutter/flutter#191595)
2026-08-27 36861262+QuncCccccc@users.noreply.github.com Deprecate legacy gen_defaults tool (flutter/flutter#191911)
2026-08-27 robert.ancell@canonical.com Fix black window in the subsurface view renderer (flutter/flutter#191850)
2026-08-27 engine-flutter-autoroll@skia.org Roll Skia from 82e972ea84b1 to 37459da0a755 (10 revisions) (flutter/flutter#191906)
2026-08-27 chris@bracken.jp iOS: Key the platform view factory registries by NSString (flutter/flutter#191855)
2026-08-27 154381524+flutteractionsbot@users.noreply.github.com Sync CHANGELOG.md from stable (flutter/flutter#191895)
2026-08-27 bkonyi@google.com [flutter_tools] Honor configured build-dir across flutter project and build targets (flutter/flutter#191592)
2026-08-27 154381524+flutteractionsbot@users.noreply.github.com Revert: Handle linear and radial gradients in UberSDF (flutter/flutter#191913)
2026-08-27 34871572+gmackall@users.noreply.github.com Explicitly disable HCPP in hybrid_android_views integration test (flutter/flutter#191894)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@victorsanni
victorsanni deleted the sliver-persistent-header-visible branch August 31, 2026 18:03
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12679)

flutter/flutter@e8dca90...8d8c1aa

2026-08-28 engine-flutter-autoroll@skia.org Roll Packages from bd3cbc1 to cd4cdd0 (15 revisions) (flutter/flutter#191965)
2026-08-28 matthiasngeo@gmail.com Bump customer testing version to pick up forui tests (flutter/flutter#191931)
2026-08-28 victorsanniay@gmail.com Use leading scroll offset instead of infinite offset to reveal pinned slivers (flutter/flutter#191329)
2026-08-28 engine-flutter-autoroll@skia.org Roll Skia from 21f71051e749 to fe0b9a5261f9 (1 revision) (flutter/flutter#191960)
2026-08-28 robert.ancell@canonical.com Share the common Linux window controller code in mixins (flutter/flutter#191930)
2026-08-28 engine-flutter-autoroll@skia.org Roll Dart SDK from 2cf2f69fd9f0 to ae63a6eca3f1 (1 revision) (flutter/flutter#191953)
2026-08-28 engine-flutter-autoroll@skia.org Roll Skia from 11e3a7cb0fd0 to 21f71051e749 (3 revisions) (flutter/flutter#191942)
2026-08-28 engine-flutter-autoroll@skia.org Roll Dart SDK from e030e77d5413 to 2cf2f69fd9f0 (2 revisions) (flutter/flutter#191934)
2026-08-28 32538273+ValentinVignal@users.noreply.github.com Remove no-shuffle in flutter tools overall experience test (flutter/flutter#191861)
2026-08-28 bkonyi@google.com [flutter_tools] Gracefully handle Windows Application Control and security policy execution blocks (flutter/flutter#191912)
2026-08-28 bkonyi@google.com [tool] Migrate ConfigCommand to modular dependency injection (flutter/flutter#190743)
2026-08-28 engine-flutter-autoroll@skia.org Roll Skia from 37459da0a755 to 11e3a7cb0fd0 (9 revisions) (flutter/flutter#191929)
2026-08-28 robert.ancell@canonical.com Connect to moved-to-rect after the window is realized (flutter/flutter#191773)
2026-08-28 chris@bracken.jp macOS: Compare accessibility strings as NSStrings in tests (flutter/flutter#191853)
2026-08-28 chris@bracken.jp macOS: Record test accessibility notifications in a dictionary (flutter/flutter#191854)
2026-08-28 engine-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from 6SXRz6wsA2Zm_rAqP... to u_fSMsPU22VvUsvSo... (flutter/flutter#191927)
2026-08-28 engine-flutter-autoroll@skia.org Roll Dart SDK from cb4c39d067f3 to e030e77d5413 (3 revisions) (flutter/flutter#191923)
2026-08-27 okorohelijah@google.com Migrate ios driver tests batch 2 to simulators (flutter/flutter#190930)
2026-08-27 bkonyi@google.com [flutter_test] Ensure LiveTestWidgetsFlutterBinding executes frame and pointer callbacks in the test zone (flutter/flutter#191595)
2026-08-27 36861262+QuncCccccc@users.noreply.github.com Deprecate legacy gen_defaults tool (flutter/flutter#191911)
2026-08-27 robert.ancell@canonical.com Fix black window in the subsurface view renderer (flutter/flutter#191850)
2026-08-27 engine-flutter-autoroll@skia.org Roll Skia from 82e972ea84b1 to 37459da0a755 (10 revisions) (flutter/flutter#191906)
2026-08-27 chris@bracken.jp iOS: Key the platform view factory registries by NSString (flutter/flutter#191855)
2026-08-27 154381524+flutteractionsbot@users.noreply.github.com Sync CHANGELOG.md from stable (flutter/flutter#191895)
2026-08-27 bkonyi@google.com [flutter_tools] Honor configured build-dir across flutter project and build targets (flutter/flutter#191592)
2026-08-27 154381524+flutteractionsbot@users.noreply.github.com Revert: Handle linear and radial gradients in UberSDF (flutter/flutter#191913)
2026-08-27 34871572+gmackall@users.noreply.github.com Explicitly disable HCPP in hybrid_android_views integration test (flutter/flutter#191894)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12679)

flutter/flutter@e8dca90...8d8c1aa

2026-08-28 engine-flutter-autoroll@skia.org Roll Packages from bd3cbc1 to cd4cdd0 (15 revisions) (flutter/flutter#191965)
2026-08-28 matthiasngeo@gmail.com Bump customer testing version to pick up forui tests (flutter/flutter#191931)
2026-08-28 victorsanniay@gmail.com Use leading scroll offset instead of infinite offset to reveal pinned slivers (flutter/flutter#191329)
2026-08-28 engine-flutter-autoroll@skia.org Roll Skia from 21f71051e749 to fe0b9a5261f9 (1 revision) (flutter/flutter#191960)
2026-08-28 robert.ancell@canonical.com Share the common Linux window controller code in mixins (flutter/flutter#191930)
2026-08-28 engine-flutter-autoroll@skia.org Roll Dart SDK from 2cf2f69fd9f0 to ae63a6eca3f1 (1 revision) (flutter/flutter#191953)
2026-08-28 engine-flutter-autoroll@skia.org Roll Skia from 11e3a7cb0fd0 to 21f71051e749 (3 revisions) (flutter/flutter#191942)
2026-08-28 engine-flutter-autoroll@skia.org Roll Dart SDK from e030e77d5413 to 2cf2f69fd9f0 (2 revisions) (flutter/flutter#191934)
2026-08-28 32538273+ValentinVignal@users.noreply.github.com Remove no-shuffle in flutter tools overall experience test (flutter/flutter#191861)
2026-08-28 bkonyi@google.com [flutter_tools] Gracefully handle Windows Application Control and security policy execution blocks (flutter/flutter#191912)
2026-08-28 bkonyi@google.com [tool] Migrate ConfigCommand to modular dependency injection (flutter/flutter#190743)
2026-08-28 engine-flutter-autoroll@skia.org Roll Skia from 37459da0a755 to 11e3a7cb0fd0 (9 revisions) (flutter/flutter#191929)
2026-08-28 robert.ancell@canonical.com Connect to moved-to-rect after the window is realized (flutter/flutter#191773)
2026-08-28 chris@bracken.jp macOS: Compare accessibility strings as NSStrings in tests (flutter/flutter#191853)
2026-08-28 chris@bracken.jp macOS: Record test accessibility notifications in a dictionary (flutter/flutter#191854)
2026-08-28 engine-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from 6SXRz6wsA2Zm_rAqP... to u_fSMsPU22VvUsvSo... (flutter/flutter#191927)
2026-08-28 engine-flutter-autoroll@skia.org Roll Dart SDK from cb4c39d067f3 to e030e77d5413 (3 revisions) (flutter/flutter#191923)
2026-08-27 okorohelijah@google.com Migrate ios driver tests batch 2 to simulators (flutter/flutter#190930)
2026-08-27 bkonyi@google.com [flutter_test] Ensure LiveTestWidgetsFlutterBinding executes frame and pointer callbacks in the test zone (flutter/flutter#191595)
2026-08-27 36861262+QuncCccccc@users.noreply.github.com Deprecate legacy gen_defaults tool (flutter/flutter#191911)
2026-08-27 robert.ancell@canonical.com Fix black window in the subsurface view renderer (flutter/flutter#191850)
2026-08-27 engine-flutter-autoroll@skia.org Roll Skia from 82e972ea84b1 to 37459da0a755 (10 revisions) (flutter/flutter#191906)
2026-08-27 chris@bracken.jp iOS: Key the platform view factory registries by NSString (flutter/flutter#191855)
2026-08-27 154381524+flutteractionsbot@users.noreply.github.com Sync CHANGELOG.md from stable (flutter/flutter#191895)
2026-08-27 bkonyi@google.com [flutter_tools] Honor configured build-dir across flutter project and build targets (flutter/flutter#191592)
2026-08-27 154381524+flutteractionsbot@users.noreply.github.com Revert: Handle linear and radial gradients in UberSDF (flutter/flutter#191913)
2026-08-27 34871572+gmackall@users.noreply.github.com Explicitly disable HCPP in hybrid_android_views integration test (flutter/flutter#191894)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD 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.

When calling Scrollable.ensureVisible to pinned SliverPersistentHeader, the view scrolls too much

3 participants