Skip to content

Slivers not being clipped in CustomScrollView with SliverMainAxisGroup on Flutter 3.13 #132788

Closed

Description

@slightfoot

Is there an existing issue for this?

Steps to reproduce

Run the code sample below you and you will see that the list items are not clipped by the CustomScrollView when using SliverMainAxisGroup. The attached video show this in action.

Wrapping the CustomScrollView in a ClipRect is a workaround at present but adds an extra ClipRectLayer. Removing the SliverMainAxisGroup widget makes the problem also go away. This explains that the issue relates to the new SliverMainAxisGroup widget and CustomScrollView.

Expected results

The CustomScrollView should adhere to it's clipBehavior and clip its content.

Actual results

The CustomScrollView should be clipping its content.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Material(
        color: Colors.red,
        child: Padding(
          padding: const EdgeInsets.symmetric(vertical: 128.0),
          child: DecoratedBox(
            position: DecorationPosition.foreground,
            decoration: BoxDecoration(
              border: Border.all(color: Colors.blue, width: 3.0),
            ),
            child: CustomScrollView(
              clipBehavior: Clip.hardEdge, // default value
              slivers: [
                SliverMainAxisGroup(
                  slivers: [
                    const SliverToBoxAdapter(
                      child: Material(
                        child: Padding(
                          padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
                          child: Text('Heading'),
                        ),
                      ),
                    ),
                    SliverList.builder(
                      itemBuilder: (BuildContext context, int index) {
                        return Material(
                          child: ListTile(
                            title: Text('Item #$index'),
                          ),
                        );
                      },
                    ),
                  ],
                ),
              ],
            ),
          ),
        ),
      ),
    ),
  );
}

Screenshots or Video

Screenshots / Video demonstration
output.mp4

Logs

No response

Flutter Doctor output

Doctor output
# flutter doctor -v
[√] Flutter (Channel stable, 3.13.0, on Microsoft Windows [Version 10.0.19045.3324], locale en-GB)
    • Flutter version 3.13.0 on channel stable at C:\Android\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision efbf63d9c6 (2 days ago), 2023-08-15 21:05:06 -0500
    • Engine revision 1ac611c64e
    • Dart version 3.1.0

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at C:\Android\SDK
    • Platform android-33, build-tools 33.0.0
    • ANDROID_SDK_ROOT = C:\Android\SDK
    • Java binary at: C:\Program Files\Java\jdk-17\bin\java
    • Java version Java(TM) SE Runtime Environment (build 17.0.7+8-LTS-224)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2019 16.11.18)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.11.32802.440
    • Windows 10 SDK version 10.0.19041.0

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[√] IntelliJ IDEA Ultimate Edition (version 2023.2)
    • IntelliJ at C:\Users\Simon\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\232.8660.185
    • Flutter plugin version 75.1.4
    • Dart plugin version 232.8660.129

[√] VS Code, 64-bit edition (version 1.27.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 2.18.0

[√] Connected device (4 available)
    • Pixel 4 (mobile)  • 99171FFAZ000F8 • android-arm64  • Android 13 (API 33)
    • Windows (desktop) • windows        • windows-x64    • Microsoft Windows [Version 10.0.19045.3324]
    • Chrome (web)      • chrome         • web-javascript • Google Chrome 115.0.5790.171
    • Edge (web)        • edge           • web-javascript • Microsoft Edge 115.0.1901.203

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Activity

  1. slightfoot commented on Aug 17, 2023

    @slightfoot
    MemberAuthor

    @Piinks @thkim1011 pulling you in as you are code owners for this.

  2. TahaTesser commented on Aug 18, 2023

    @TahaTesser
    Contributor

    Great catch @slightfoot. I can see on the latest master too.

    flutter doctor -v
    [✓] Flutter (Channel master, 3.14.0-8.0.pre.9, on Microsoft Windows [Version 10.0.22621.2134], locale en-US)
        • Flutter version 3.14.0-8.0.pre.9 on channel master at C:\Users\Taha\Code\flutter
        • Upstream repository [email protected]:TahaTesser/flutter.git
        • FLUTTER_GIT_URL = [email protected]:TahaTesser/flutter.git
        • Framework revision 6875827f46 (16 minutes ago), 2023-08-18 20:48:05 +0300
        • Engine revision 58f7d8ee3e
        • Dart version 3.2.0 (build 3.2.0-84.0.dev)
        • DevTools version 2.26.1
    
    [✓] Windows Version (Installed version of Windows is version 10 or higher)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at C:\Users\Taha\Code\android-sdk
        • Platform android-34, build-tools 34.0.0
        • ANDROID_HOME = C:\Users\Taha\Code\android-sdk
        • Java binary at: C:\Users\Taha\Code\android-studio\jbr\bin\java
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
        • All Android licenses accepted.
    
    [✓] Chrome - develop for the web
        • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
    
    [✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.1)
        • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
        • Visual Studio Community 2022 version 17.7.34009.444
        • Windows 10 SDK version 10.0.22621.0
    
    [✓] Android Studio (version 2023.1)
        • Android Studio at C:\Users\Taha\Code\android-studio
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
    
    [✓] VS Code (version 1.81.1)
        • VS Code at C:\Users\Taha\AppData\Local\Programs\Microsoft VS Code
        • Flutter extension version 3.70.0
    
    [✓] Connected device (3 available)
        • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.2134]
        • Chrome (web)      • chrome  • web-javascript • Google Chrome 115.0.5790.173
        • Edge (web)        • edge    • web-javascript • Microsoft Edge 115.0.1901.203
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
  3. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    f: scrollingViewports, list views, slivers, etc.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Aug 18, 2023
  4. self-assigned this
    on Aug 21, 2023
  5. slightfoot commented on Aug 21, 2023

    @slightfoot
    MemberAuthor

    🥳 Thanks @Piinks!

  6. github-actions commented on Sep 11, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  7. locked as resolved and limited conversation to collaborators on Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions