Skip to content

CustomScrollView's Scrollbar is not draggable when using a center key for a empty sliverlist with an anchor of 1.0 #178863

Closed

Description

@JuubiSnake

Steps to reproduce

  1. Create a CustomScrollView.
  2. Give it a center key.
  3. Assign it a anchor of 1.0.
  4. Pass in a normal sliverlist with some children such that the viewport of the application will become scrollable.
  5. Pass in a sliverlist with no children present and have that sliverlist hold the center key.

Expected results

When clicking and dragging the scollbar I should be able to navigate up/down the list.

Actual results

When clicking and dragging the scollbar via the mouse you are not able to navigate up/down the list (you can however scroll it - as shown in the provided video).

Code sample

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

/// 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> {
  @override
  Widget build(BuildContext context) {
    final items = List<int>.generate(100, (index) => index);

    const Key centerKey = ValueKey<String>('bottom-sliver-list');
    return Scaffold(
      appBar: AppBar(
        title: const Text('Bug demo'),
      ),
      body: CustomScrollView(
        center: centerKey,
        anchor: 1.0,
        slivers: <Widget>[
          SliverList.builder(
            itemCount: items.length,
            itemBuilder: (BuildContext context, int index) {
              return Container(
                alignment: Alignment.center,
                color: Colors.blue[200 + items[index] % 4 * 100],
                height: 100 + items[index] % 4 * 20.0,
                child: Text('Item: ${items[index]}'),
              );
            },
          ),
          SliverList.builder(
            key: centerKey,
            itemCount: 0,
            itemBuilder: (BuildContext context, int index) {
              return Text("This is not going to be present");
            },
          ),
        ],
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Screen.Recording.2025-11-20.at.13.23.08.mov

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.35.4, on macOS 15.6 24G84 darwin-arm64, locale en-GB) [96ms]
    • Flutter version 3.35.4 on channel stable at /opt/homebrew/share/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d693b4b9db (9 weeks ago), 2025-09-16 14:27:41 +0000
    • Engine revision c298091351
    • Dart version 3.9.2
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop,
      enable-android, enable-ios, cli-animations, enable-lldb-debugging

[✗] Android toolchain - develop for Android devices [58ms]
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/to/macos-android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [303ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16F6
    • CocoaPods version 1.16.2

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

[!] Android Studio (not installed) [4ms]
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/macos-android-setup for detailed instructions).

[✓] Connected device (3 available) [5.5s]
...

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

! Doctor found issues in 2 categories.

Activity

  1. tustvold commented on Nov 20, 2025

    @tustvold

    This appears to be a bug in Scrollbar in particular

    bool _canHandleScrollGestures() {
        return enableGestures &&
            _effectiveScrollController != null &&
            _effectiveScrollController!.positions.length == 1 &&
            _effectiveScrollController!.position.hasContentDimensions &&
            _effectiveScrollController!.position.maxScrollExtent > 0.0;
      }
    

    I think should be

    bool _canHandleScrollGestures() {
        return enableGestures &&
            _effectiveScrollController != null &&
            _effectiveScrollController!.positions.length == 1 &&
            _effectiveScrollController!.position.hasContentDimensions &&
            _effectiveScrollController!.position.maxScrollExtent > _effectiveScrollController!.position.minScrollExtent;
      }
    

    Otherwise the scrollbar only enables gestures when there is a positive scroll extent.

  2. tirth-patel-nc commented on Nov 21, 2025

    @tirth-patel-nc
    Member

    Thanks for the report. Seeing the same behaviour with latest SDK versions.

    stable : 3.38.2
    master : 3.39.0-1.0.pre-227
    
  3. added
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    f: scrollingViewports, list views, slivers, etc.
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    and removed
    in triagePresently being triaged by the triage team
    on Nov 21, 2025
  4. github-actions commented on Dec 24, 2025

    @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.

  5. locked as resolved and limited conversation to collaborators on Dec 24, 2025
  6. added a commit that references this issue on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: scrollingViewports, list views, slivers, etc.found in release: 3.38Found to occur in 3.38found in release: 3.39Found to occur in 3.39frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions