Repository navigation
Theme's highlightColor fails to change Scrollbar color #36603
Copy link
Copy link
Closed
Labels
f: 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.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages
Description
Steps to Reproduce
void main() => runApp(MaterialApp(home: TestPage()));
class TestPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Theme(
data: ThemeData(highlightColor: Colors.green), // doesn't change Scrollbar color
child: Scaffold(
body: Scrollbar(
child: ListView.builder(
itemBuilder: (_, i) => ListTile(title: Text("Item ${i}")),
itemCount: 100,
),
),
),
);
}
}
Run this minimal code, and you can see the color of the Scrollbar isn't changed. It used to work before in previous version of flutter (don't remember the number).
Flutter doctor:
[✓] Flutter (Channel dev, v1.8.0, on Mac OS X 10.14 18A389, locale en-GB)
• Flutter version 1.8.0 at /flutter
• Framework revision 2fefa8c731 (3 weeks ago), 2019-07-01 11:33:22 -0700
• Engine revision 45b66b722e
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/chocolate/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 10.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.1, Build version 10B61
• CocoaPods version 1.7.2
[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4
[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 37.1.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1343-b01)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
f: 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.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages
Activity
justinmc commentedon Jul 22, 2019
@dark-chocolate Are you talking about iOS specifically? It looks like the scrollbar color for iOS is hardcoded, but on Android it should change with the theme's highlightColor.
justinmc commentedon Jul 22, 2019
It seems like in native iOS development the scrollbar's color can be changed between light and dark, but not fully customized. https://stackoverflow.com/questions/12005187/ios-changing-uiscrollview-scrollbar-color-to-different-colors
darrenaustin commentedon Jul 24, 2019
As @justinmc mentions this appears to be working by design. Scrollbars adapt their appearance to try and mimic the native controls on the platform they are running on. If you deploy this sample app to an Android device it will render the scrollbar as green. However, if you deploy it to an iOS device, it will not change the color as iOS scrollbars are not customizable and Flutter is following that design.
If you deploy this app to an Android device are you still not seeing a green scrollbar?
dark-chocolate commentedon Jul 25, 2019
@justinmc, yes I was talking about for iOS, and @darrenaustin sir you are right it is working in Android, but as far as I remember, it used to change color in iOS too in previous updates, I tested it on Jan-Feb 2019 not sure which flutter version I was using. Have you guys changed anything afterwards?
justinmc commentedon Jul 25, 2019
It looks like it's been hard coded since CupertinoScrollbar was created in #13290. Maybe you were using a Material Scrollbar on an iOS device before?
dark-chocolate commentedon Jul 26, 2019
@justinmc I was/am using a normal
Scrollbarfrom the packageflutter/material.dart. I never usedCupertinoScrollbar. So, can I change color of theScrollbarin iOS with any means except changing the hardcoded value from the source code?justinmc commentedon Jul 26, 2019
Scrollbarwill automatically useCupertinoScrollbarunder the hood on iOS now. So no you can't change the color of the scrollbar on iOS without modifying the source code.This seems like something we shouldn't officially support unless iOS supports it, so I'm going to close this issue. If you need help figuring out how to hack it to change the color definitely let me know though.
PawlikMichal25 commentedon Oct 21, 2020
Not ideal, but this is a workaround which we can use for now:
github-actions commentedon Aug 10, 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.