-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Steps to reproduce
- A stateful widget builds a
Scrollbar, wrapping its child. This child is expected to contain aSingleChildScrollView. Initially, the widget has no scroll controller, so itsScrollbaris built withcontroller: null,thumbVisibility: falseandinteractive: false. - In a next frame, a scroll controller becomes available, so
Scrollbaris rebuilt with a non-nullcontroller,thumbVisibility: trueandinteractive: true. The controller is not yet attached at this point, as the descendantSingleChildScrollViewstill has to be rebuilt with the new controller, too.
Expected results
The scrollbar is now working interactively (i.e. can be used to change the current scroll offset through the provided controller).
Actual results
The scrollbar is made interactive, as expected, but first an assertion failure is triggered in the RawScrollbarState underlying the Scrollbar widget:
══╡ EXCEPTION CAUGHT BY ANIMATION LIBRARY ╞══════════════════════
The following assertion was thrown while notifying status
listeners for AnimationController:
The Scrollbar's ScrollController has no ScrollPosition attached.
A Scrollbar cannot be painted without a ScrollPosition.
The Scrollbar attempted to use the provided ScrollController.
This ScrollController should be associated with the ScrollView
that the Scrollbar is being applied to.
When providing your own ScrollController, ensure both the
Scrollbar and the Scrollable widget use the same one.
When the exception was thrown, this was the stack
The AnimationController notifying status listeners was:
AnimationController#ab7ae(▶ 0.000)
═════════════════════════════════════════════════════════════════
This assertion is checked synchronously at build time, in RawScrollbarState._debugCheckHasValidScrollPosition, called from RawScrollbarState._validateInteractions, which is a status listener of RawScrollbarState._fadeOutAnimationController. This animation controller is started at build time, in RawScrollbarState.didUpdateWidget, causing the assertion check to be performed at build time as well.
There is another assertion to verify the same thing, but that is scheduled as a post-frame-callback (in RawScrollbarState._debugScheduleCheckHasValidScrollPosition), when you can more reasonably assume that a controller will have been attached.
On a side note, I'm not sure whether this claim that "A Scrollbar cannot be painted without a ScrollPosition." is true. Painting the scrollbar seems to be based on information from Scroll(Metrics)Notification. Maybe complaining about an unattached ScrollController could be delayed up to the point where one is really needed: actual scrollbar interaction?
Code sample
See https://dartpad.dev/d564e246c3fccfe638a7b9b5e0ec9ced. Perform step 2 (the assignment of a scroll controller, thumbVisibility: true and interactive: true) by flipping the switch at the top.
Screenshots or Video
No response
Logs
Flutter Doctor output
[!] Flutter (Channel [user-branch], 3.27.3, on macOS 15.5 24F74 darwin-arm64, locale en-US)
! Flutter version 3.27.3 on channel [user-branch] at /Users/heinrich.janzing/source/flutter
Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
! Upstream repository unknown source is not a standard remote.
Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
• Framework revision c519ee916e (6 months ago), 2025-01-21 10:32:23 -0800
• Engine revision e672b006cb
• Dart version 3.6.1
• DevTools version 2.40.2
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[!] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
• Android SDK at /Users/heinrich.janzing/Library/Android/sdk
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/to/macos-android-setup for more details.
[!] Xcode - develop for iOS and macOS (Xcode 16.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16F6
✗ CocoaPods not installed.
CocoaPods is a package manager for iOS or macOS platform code.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/to/platform-plugins
For installation instructions, see https://guides.cocoapods.org/using/getting-started.html#installation
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2025.1)
• 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+-13391695-b895.109)
[✓] VS Code (version 1.101.0)
• VS Code at /Users/heinrich.janzing/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.114.0
[✓] Connected device (3 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 15.5 24F74 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.5 24F74 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 138.0.7204.101
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 3 categories.