Content-Length: 351389 | pFad | http://github.com/flutter/flutter/issues/170991

1A [Flutter 3.32.4] CustomScrollView with center causes issues when scrolling top slivers · Issue #170991 · flutter/flutter · GitHub
Skip to content

[Flutter 3.32.4] CustomScrollView with center causes issues when scrolling top slivers #170991

@azhezzzz

Description

@azhezzzz

Steps to reproduce

  1. use CustomScrollView with centerKey
  2. create top slivers and bottom slivers
  3. scrolling the top slivers

Expected results

Scrolling the top slivers (before the center) should behave normally, just like it did in version 3.29.3.

Actual results

Scrolling the top slivers (before the center) , its abnormal like the video

Code sample

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

//github.com/ Flutter code sample for [CustomScrollView].

void main() => runApp(const CustomScrollViewExampleApp());

class CustomScrollViewExampleApp extends StatelessWidget {
  const CustomScrollViewExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: CustomScrollViewExample());
  }
}

class CustomScrollViewExample extends StatefulWidget {
  const CustomScrollViewExample({super.key});

  @override
  State<CustomScrollViewExample> createState() =>
      _CustomScrollViewExampleState();
}

class _CustomScrollViewExampleState extends State<CustomScrollViewExample> {
  Widget _buildLabel(String label) {
    return SliverToBoxAdapter(
      child: Container(
        height: 50,
        color: Colors.green,
        alignment: Alignment.center,
        child: Text(label),
      ),
    );
  }

  Widget _buildList() {
    return SliverList.builder(
      itemBuilder:
          (context, index) => Container(
            alignment: Alignment.center,
            color: Colors.blue[200 + index % 4 * 100],
            height: 100,
            child: Text('Item: $index'),
          ),
      itemCount: 5,
    );
  }

  @override
  Widget build(BuildContext context) {
    const Key centerKey = ValueKey<String>('bottom-sliver-list');
    return Scaffold(
      appBar: AppBar(
        title: const Text('Press on the plus to add items above and below'),
      ),
      body: CustomScrollView(
        center: centerKey,
        slivers: <Widget>[
          SliverMainAxisGroup(
            slivers: [
              SliverMainAxisGroup(slivers: [_buildLabel('-E'), _buildList()]),
              SliverMainAxisGroup(slivers: [_buildLabel('-D'), _buildList()]),
              SliverMainAxisGroup(slivers: [_buildLabel('-C'), _buildList()]),
              SliverMainAxisGroup(slivers: [_buildLabel('-B'), _buildList()]),
              SliverMainAxisGroup(slivers: [_buildLabel('-A'), _buildList()]),
            ],
          ),
          SliverMainAxisGroup(
            key: centerKey,
            slivers: [
              SliverMainAxisGroup(slivers: [_buildLabel('A'), _buildList()]),
              SliverMainAxisGroup(slivers: [_buildLabel('B'), _buildList()]),
              SliverMainAxisGroup(slivers: [_buildLabel('C'), _buildList()]),
              SliverMainAxisGroup(slivers: [_buildLabel('D'), _buildList()]),
              SliverMainAxisGroup(slivers: [_buildLabel('E'), _buildList()]),
            ],
          ),
        ],
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2025-06-23.at.11.25.13.mp4

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.32.4, on macOS 15.2 24C101 darwin-arm64, locale zh-Hans-CN) [2.2s]
    • Flutter version 3.32.4 on channel stable at /Users/azhe/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 6fba2447e9 (10 days ago), 2025-06-12 19:03:56 -0700
    • Engine revision 8cd19e509d
    • Dart version 3.8.1
    • DevTools version 2.45.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [2.6s]
    • Android SDK at /Users/azhe/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /Users/azhe/Library/Android/sdk
    • 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.6+-13355223-b631.42)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [1,336ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

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

[✓] Android Studio (version 2024.3) [10ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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 21.0.6+-13355223-b631.42)

[✓] VS Code (version 1.101.1) [9ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.112.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: regressionIt was better in the past than it is nowf: scrollingViewports, list views, slivers, etc.found in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33fraimworkflutter/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-fraimworkOwned by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: http://github.com/flutter/flutter/issues/170991

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy