Skip to content

Scrollbar unexpectedly jumps to the starting position when dragging down, with CustomScrollView's center was set #170246

Closed
@greyovo

Description

@greyovo

Steps to reproduce

  1. In a CustomScrollView widget, set the center property with a GlobalKey
  2. In the slivers, place some sliver widgets, and ensure one of them is set with the same GlobalKey
  3. Wrap the CustomScrollView with a RawScrollBar
  4. First scroll the screen to top, then drag the scrollbar to move down a small distance.

Expected results

The scrollbar should move down within a small distance according to the user's gestures.

Actual results

The scrollbar unexpectedly jumps to the starting position and then scrolls down.

Code sample

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  final centerKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text("CustomScrollView demo")),
        body: RawScrollbar(
          thumbVisibility: true,
          thumbColor: Colors.blueAccent,
          thickness: 20,
          child: CustomScrollView(
            center: centerKey,
            slivers: [
              SliverToBoxAdapter(child: Container(height: 600.0, color: Colors.redAccent)),
              SliverToBoxAdapter(key: centerKey, child: Container(height: 600.0)),
              SliverToBoxAdapter(child: Container(height: 600.0, color: Colors.amberAccent)),
            ],
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
2025-06-09.20.18.06.mov

Logs

Logs
None

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.32.2, on macOS 15.2 24C101 darwin-arm64, locale zh-Hans-CN) [532ms]
    • Flutter version 3.32.2 on channel stable at /Users/greyhuiliu/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8defaa71a7 (5 days ago), 2025-06-04 11:02:51 -0700
    • Engine revision 1091508939
    • Dart version 3.8.1
    • DevTools version 2.45.1
    • Pub download mirror https://mirrors.tencent.com/dart-pub/
    • Flutter download mirror https://mirrors.tencent.com/flutter/

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [1,585ms]
    • Android SDK at /Users/greyhuiliu/Library/Android/sdk
    • Platform android-35, 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+-12932927-b750.29)
    • All Android licenses accepted.

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

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

[✓] Android Studio (version 2024.3) [15ms]
    • 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.5+-12932927-b750.29)

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

[✓] Proxy Configuration [52ms]
    • HTTP_PROXY is set
    • NO_PROXY is localhost,127.0.0.1,::1
    • NO_PROXY contains localhost
    • NO_PROXY contains 127.0.0.1
    • NO_PROXY contains ::1

[✓] Connected device (3 available) [6.2s]
    • iPhone 16 (mobile) • BB471954-F1E7-4186-A8F7-5528FF926CC7 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-3 (simulator)
    • macOS (desktop)    • macos                                • darwin-arm64   • macOS 15.2 24C101 darwin-arm64
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 137.0.7151.69
    ! Error: Browsing on the local area network for Grey's. 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 [442ms]
    • All expected network resources are available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: material designflutter/packages/flutter/material repository.f: scrollingViewports, list views, slivers, etc.found in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33frameworkflutter/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-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions