Repository navigation
[Web][Channel beta] Unable to paint new Scrollbar #75643
Copy link
Copy link
Closed
Labels
d: stackoverflowGood question for Stack OverflowGood question for Stack Overflowf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Description
I really can't find a way to change the default color of the new Scrollbar, I can change the Thumb color using the RawScrollbar class but not the trackColor and the trackBorderColor.
I tried with the ScrollbarThemeData and the ScrollbarPainter but the Scrollbar class just ignores them.
Related to #70866
Steps to Reproduce
Clone the sample code: Example
You can switch the body of the scaffold between Test1(ScrollbarThemeData) and Test2(ScrollbarPainter).
Expected results: Thumb, Track and Track border should be painted.
Actual results: They ignore the data colors.
Logs
[√] Flutter (Channel beta, 1.26.0-17.3.pre, on Microsoft Windows [Versión 10.0.19042.630], locale es-ES)
• Flutter version 1.26.0-17.3.pre at C:\flutter
• Framework revision 4b50ca7f7f (4 days ago), 2021-02-04 19:44:27 -0800
• Engine revision 2c527d6c7e
• Dart version 2.12.0 (build 2.12.0-259.8.beta)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\F-Desktop\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] IntelliJ IDEA Ultimate Edition (version 2020.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.3
• Flutter plugin version 53.0.5
• Dart plugin version 203.6912
[√] VS Code, 64-bit edition (version 1.50.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.16.0
[√] Connected device (2 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.146
• Edge (web) • edge • web-javascript • Microsoft Edge 87.0.664.75
• No issues found!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
d: stackoverflowGood question for Stack OverflowGood question for Stack Overflowf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Activity
Piinks commentedon Feb 8, 2021
Copied reproduction code over from link for reference:
Hi @franarolas I can see what is going on here...
Regarding Test1, the
ScrollbarThemecannot be within the same context of theScrollbar. When the Scrollbar callsTheme.of(context)to inform the coloring, it does not find the one you intend it to find because it is built in the same context. This is similar to trying to callScaffold.of(context)within the same context that the Scaffold is being built, it will not get the right one.You can fix this by adding a Builder in between to get a new context, like this:
Or, you can just provide the
ScrollbarThemeDatato theThemeDatayou are already creating above in yourMaterialApp:As for Test2, I do not expect this to work. The
Scrollbarcreates and uses its own painter, so wrapping aScrollbarin aScrollbarPainterwon't affect theScrollbar.franarolas commentedon Feb 8, 2021
@Piinks
Oh, I see my mistake there, I haven't had this in mind, I'm sorry you are completely right, thank you, putting the scrollbartheme in the material theme works as expected.
If this is the expected behaviour, I will just close the issue.
Thank you again.
sedagurocak commentedon Jun 16, 2021
I have this problem on app. The track color is not change when I use ScrollBartheme. How can I change track color on mobile app.
data: ScrollbarThemeData(
thumbColor: MaterialStateColor.resolveWith((states) => Colors.red),
trackBorderColor: MaterialStateColor.resolveWith((states) => Colors.green),
trackColor: MaterialStateColor.resolveWith((states) => Colors.blue),
),
I need to do this;

github-actions commentedon Jul 31, 2021
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 -vand a minimal reproduction of the issue.