Skip to content

The SliverMainAxisGroup.cacheOrigin is not consistent with CustomScrollView #175759

@manu-sncf

Description

@manu-sncf

Steps to reproduce

Add the test from code sample in file sliver_main_axis_group_test.dart of Flutter project.

Launch the test with SliverMainAxisGroup and launch with unwrapping SliverMainAxisGroup. The cacheOrgin values are different.

In one of our mobile application, we have inconsistent behavior on cached sliver widget when scrolling with and without SliverMainAxisGroup.

Expected results

The constraints.cacheOrigin of SliverList should be the same with or without SliverMainAxisGroup : -250.0

Actual results

The actual cacheOrigin is 0.

Code sample

testWidgets('SliverMainAxisGroup has consistent cacheOrigin', (WidgetTester tester) async {
    const Widget item = SizedBox.square(dimension: 50);

    await tester.pumpWidget(
      MaterialApp(
        home: CustomScrollView(
          slivers: <Widget>[
            SliverMainAxisGroup(
              slivers: <Widget>[
                const PinnedHeaderSliver(child: SizedBox(height: 500)),
                SliverList.builder(
                  itemCount: 100,
                  itemBuilder: (BuildContext context, int index) => item,
                ),
                const SliverToBoxAdapter(child: item),
              ],
            ),
          ],
        ),
      ),
    );

    await tester.scrollUntilVisible(find.byType(SliverToBoxAdapter), 500);
    await tester.pumpAndSettle();

    final RenderSliver sliverList =
        find.byType(SliverList).evaluate().single.findRenderObject()! as RenderSliver;

    expect(sliverList.constraints.cacheOrigin, -250.0);
    expect(sliverList.constraints.remainingCacheExtent, 1100);
  });

Screenshots or Video

No response

Logs

No error visible.

Flutter Doctor output

Doctor output
[✓] Flutter (Channel master, 3.37.0-1.0.pre-217, on macOS 15.6.1 24G90 darwin-arm64, locale fr-FR) [4,1s]
    • Flutter version 3.37.0-1.0.pre-217 on channel master at /Users/emmanuel_lefebvre/fvm/versions/master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8040ebc803 (33 hours ago), 2025-09-20 20:52:34 -0700
    • Engine revision 9ff2767f3c
    • Dart version 3.10.0 (build 3.10.0-227.0.dev)
    • DevTools version 2.50.0
    • Pub download mirror https://artifact.socrate.vsct.fr/artifactory/api/pub/all-pub
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [4,8s]
    • Android SDK at /Users/emmanuel_lefebvre/Library/Android/sdk
    • Emulator version 36.1.9.0 (build_id 13823996) (CL:N/A)
    • Platform android-36, build-tools 35.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.0) [4,1s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17A324
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [9ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (2 available) [13,7s]    
    • macOS (desktop) • macos  • darwin-arm64   • macOS 15.6.1 24G90 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 140.0.7339.186
    ! Error: Browsing on the local area network for iPhone XS. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources [180ms]
    • All expected network resources are available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our testsf: material designflutter/packages/flutter/material repository.f: scrollingViewports, list views, slivers, etc.found in release: 3.35Found to occur in 3.35found in release: 3.37Found to occur in 3.37frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions