Repository navigation
Description
Horizontal Scrollables in a list view are causing the Scrollbars of the containing Scrollable to be drawn. Ideally, the Scrollbar would only show for the axis of the immediate Scrollable descendent, or perhaps allow consumers to specify the allowed depth of Scrollable to listen to.
Steps to Reproduce
- Create a ListView and Wrap with a Scrollbar widget
- Place a horizontal PageView widget in a list item
- Swipe the PageView
- Observe that the scrollbar for the ListView is scrolling horizontally
I created a sample app to demonstrate:
https://github.com/coreysprague/flutter_nested_pageview_scrollbars
flutter doctor -v
[✓] Flutter (Channel unknown, v1.7.8+hotfix.3, on Mac OS X 10.14.5 18F132,
locale en-US)
• Flutter version 1.7.8+hotfix.3 at /Users/cosprague/Library/Code/flutter
• Framework revision b712a17 (9 days ago), 2019-07-09 13:14:38 -0700
• Engine revision 54ad777fd2
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/cosprague/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /Users/cosprague/Library/Android/sdk
• 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.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• CocoaPods version 1.7.1
[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 36.0.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[✓] VS Code (version 1.36.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.2.0
[✓] Connected device (3 available)
• iPhone Xs • CB2CBFCD-D56F-412E-B17C-B5908F7D749E • ios •
com.apple.CoreSimulator.SimRuntime.iOS-12-2 (simulator)
• macOS • macOS • darwin-x64 • Mac OS X 10.14.5 18F132
• web • web • web-javascript • Google Chrome 75.0.3770.142
• No issues found!

Activity
coreysprague commentedon Jul 19, 2019
I found a workaround for this. I can wrap the nested scrollview with this code:
this will prevent the notification event from bubbling up to the parent scrollview.
I was also able to solve it by forking Scrollbar & CupertinoScrollbar and doing an early return in the scroll handler if the depth was greater than 0 (but the earlier solution of trapping the notification is more elegant).
Regardless, the current default behavior doesn't seem intuitive or allow people to fall into the pit of success.
Piinks commentedon Feb 27, 2020
Hey @coreysprague Thanks for bring this to our attention, and for the really good reproduction.
I am not sure this is a regression, I checked out 1.5.4 and ran your repro and found that the Scrollbars are still there, they are just a little less noticeable along the edges of the screen.
I think they are more apparent in 1.7.8 because #31763 added padding to the Scrollbars, bringing them more into view.
I don't know what the expected behavior should be here then. I could see expecting either case (to show the
Scrollbaror not) depending on the situation. Perhaps this is something we can make configurable on theScrollbar?coreysprague commentedon Feb 27, 2020
Hi @Piinks
Making it configurable on the ScrollBar would make sense. It seems like it would make the most sense to default the behavior to only respond to scroll notifications from the immediate descendent, and optionally respond to all? That would of course be a breaking change, but I think it would be the case that most use cases would expect.
[-]Nested Scrollable is displaying Scrollbars on outer Scrollable in Flutter 1.7.8-hotfix-3[/-][+]Scrollbar should have option to specify effective depth for nested scrollable[/+]Piinks commentedon Feb 27, 2020
Thanks for coming back! :)
That sounds like a good idea to me! We try not to make breaking changes, so we may configure it the other way around where the default behavior is the current behavior. That way no one is broken.
coreysprague commentedon Mar 6, 2020
@Piinks -- I just wanted to throw out another thought that might also address this problem (and maybe is easier to solve).
I suspect this issue is primarily isolated to when you have nested content that scrolls perpendicular to the parent's scrollview
I wonder if instead of making Scrollbar aware of nesting... if instead scrollbar could have a property to define which axes to show the scroll indicators. It could default to both horizontal & vertical, but an optional parameter could specify vertical only (or horizontal only).
I could see this feature potentially having value outside of the nesting use case as well.
carmas123 commentedon Aug 2, 2020
I think that the
ScrollBarneed to be visibile only for direct child and not for all tree.If I've a multiple childs into a
SingleChildScrollViewand I want to show scrollbar for all childs theScrollBarwidget must have a simple parameter like "infiniteDeep" that make to be able to have scrollbar for all the tree.But if I need to have the scrollbar only for the main container like a
SingleChildScrollViewI leave this parameter false oras said by @coreysprague we need to have a parameter to specify the effective depth of scrollbar.
simrat39 commentedon Sep 1, 2020
Thanks! Works perfect for me
For anyone who has a lot of scrollviews, you can use this extension:
pedromassangocode commentedon Dec 9, 2020
I was able to reproduce this with the latest
masterandbetachannel. Code based on #66444 that was closed as duplicate.I don't see this as
new featurebut as abugbecause it is an unwanted behavior comparing with the native implementations. So, removingnew featurelabel. Feel free to add it back if I'm wrong.Edit: Ok, this seems to a new feature, @Piinks I think this is not similar to #66444. I see #66444 as to not show/scroll multiple scrollbar when only one should scroll. See image bellow.
flutter doctor -v
alaydeliwala commentedon Jan 4, 2021
I tried this and it worked (partially). With this workaround, a double scrollbar does not show up, however, no scrollbar shows up for the nested scroll view. Is there a workaround for that?
As you can see in the gif above, the vertical scroll displays a scrollbar but when I try to scroll horizontally on the call field, no scrollbar shows up.
github-actions commentedon Aug 7, 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.