You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
isAlwaysShown property doesn't work with nested Scrollbar #70380
The vertical Scrollbar is added inside the horizontal Scrollbar and isAlwaysShown property is set true for both, the vertical Scrollbar is shown initially.
Actual Behavior: While scrolling either vertical or horizontal, the corresponding Scrollbar alone displayed.
Expected behavior: Both the horizontal and vertical Scrollbars should be shown at the same time.
changed the title [-]Scrollbar isAlwaysShown property is not shown when nested[/-][+]isAlwaysShown property doesn't work with nested Scrollbar[/+]on Nov 12, 2020
@TahaTesser This is exactly what I am facing.
In your example, the vertical scrollbar is nested in the horizontal one.
This vertical scrollbar is visible only when user scrolls horizontally to the right edge.
Beside the problem above, there's another issue when adding LayoutBuilder to control Scrollbar which has a ScrollController and isAlwaysShown: true.
In the example above, when we expand the screen (web or desktop) from ex. 900dp width to ex. 1000dp width, an exception is thrown:
======== Exception caught by scheduler library =====================================================
The following assertion was thrown during a scheduler callback:
The Scrollbar's ScrollController has no ScrollPosition attached.
A Scrollbar cannot be painted without a ScrollPosition.
The Scrollbar attempted to use the PrimaryScrollController. 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:
#0 RawScrollbarState._maybeTriggerScrollbar.<anonymous closure>.<anonymous closure> (package:flutter/src/widgets/scrollbar.dart:960:13)
#1 RawScrollbarState._maybeTriggerScrollbar.<anonymous closure> (package:flutter/src/widgets/scrollbar.dart:985:10)
#2 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#3 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1090:9)
#4 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:998:5)
...
====================================================================================================
flutter doctor -v
[√] Flutter (Channel beta, 2.2.0-10.3.pre, on Microsoft Windows [Version 10.0.19042.964], locale en-DE)
• Flutter version 2.2.0-10.3.pre at C:\...\flutter
• Framework revision 06e2fd6357 (5 days ago), 2021-05-08 11:28:22 -0700
• Engine revision a123e75c60
• Dart version 2.13.0 (build 2.13.0-211.14.beta)
I believe this has been resolved, running today on the latest master, both scrollbars are visible. Although in the current configuration, one of them is out of view until you scroll far enough to the other edge to see it. This can be fixed by rearranging the widgets and setting the notification predicate for one of the scrollbars.
Here is a simplified version of the original code:
Code Before
import'package:flutter/material.dart';
main() =>runApp(MaterialApp(
// Only setting isAlwaysShown here for simplicity :)
theme:ThemeData(scrollbarTheme:ScrollbarThemeData(isAlwaysShown:true)),
// I have added this since we are manually adding scrollbars, on// desktop scrollbars are added automatically.
scrollBehavior:ScrollBehavior().copyWith(scrollbars:false),
home:MyApp(),
));
classMyAppextendsStatefulWidget {
@overrideMyAppStatecreateState() =>MyAppState();
}
classMyAppStateextendsState<MyApp> {
ScrollController verticalController =ScrollController();
ScrollController horizontalController =ScrollController();
@overrideWidgetbuild(BuildContext context) {
returnScaffold(
appBar:AppBar(title:Text('ScrollBar')),
body:Scrollbar(
controller: horizontalController,
child:SingleChildScrollView(
controller: horizontalController,
scrollDirection:Axis.horizontal,
// In this configuration, the Scrollbar is contained inside of// the horizontal scroll view. This is why we cannot see it// until we scroll all the way over.
child:Scrollbar(
controller: verticalController,
child:SingleChildScrollView(
controller: verticalController,
child:Column(
children: [
Row(
children: [
for (int i =0; i <4; i++) getContainer(i),
],
),
Row(
children: [
for (int i =0; i <4; i++) getContainer(i+1),
],
),
Row(
children: [
for (int i =0; i <4; i++) getContainer(i),
],
),
Row(
children: [
for (int i =0; i <4; i++) getContainer(i+1),
],
)
],
),
),
),
),
));
}
}
WidgetgetContainer(int i) {
returnContainer(
color: i.isEven ?Colors.white :Colors.black,
height:200,
width:200,
);
}
If we move the vertical scrollbar above the horizontal scroll view, then we can see both scrollbars above the 2D scroll view.
Moving our vertical Scrollbar further away from the vertical scroll view like this changes the ScrollNotification depth, but @xu-baolin made it possible to configure this in #74104 with Scrollbar.notificationPredicate.
So the updated code looks like this:
Code After
import'package:flutter/material.dart';
main() =>runApp(MaterialApp(
// Only setting isAlwaysShown here for simplicity :)
theme:ThemeData(scrollbarTheme:ScrollbarThemeData(isAlwaysShown:true)),
// I have added this since we are manually adding scrollbars, on// desktop scrollbars are added automatically.
scrollBehavior:ScrollBehavior().copyWith(scrollbars:false),
home:MyApp(),
));
classMyAppextendsStatefulWidget {
@overrideMyAppStatecreateState() =>MyAppState();
}
classMyAppStateextendsState<MyApp> {
ScrollController verticalController =ScrollController();
ScrollController horizontalController =ScrollController();
@overrideWidgetbuild(BuildContext context) {
returnScaffold(
appBar:AppBar(title:Text('ScrollBar')),
body:Scrollbar(
controller: horizontalController,
// Move vertical scrollbar so it is not inside of horizontal scroll view
child:Scrollbar(
// Update notification predicate as the scroll view depth is greater// from this new spot in the widget tree
notificationPredicate: (notification) => notification.depth ==1,
controller: verticalController,
child:SingleChildScrollView(
controller: horizontalController,
scrollDirection:Axis.horizontal,
child:SingleChildScrollView(
controller: verticalController,
child:Column(
children: [
Row(
children: [
for (int i =0; i <4; i++) getContainer(i),
],
),
Row(
children: [
for (int i =0; i <4; i++) getContainer(i+1),
],
),
Row(
children: [
for (int i =0; i <4; i++) getContainer(i),
],
),
Row(
children: [
for (int i =0; i <4; i++) getContainer(i+1),
],
)
],
),
),
),
),
));
}
}
WidgetgetContainer(int i) {
returnContainer(
color: i.isEven ?Colors.amberAccent[100] :Colors.blueAccent[100],
height:200,
width:200,
);
}
And it looks like this! :)
2D_scrollbar.mov
I am going to close this as it appears to be working properly, but feel free to re-open if we need to investigate further! Thank you!
I do not think that feature will work for this case though, as the Scrollbars are applied to each scrollable individually. That would result in the situation above where one of them was contained in the scrollable and could not be seen until you scrolled to the other edge. For now, this 2D case should use the manual configuration above.
Thanks @Piinks for the link, I will check it later.
I do not think that feature will work for this case though, as the Scrollbars are applied to each scrollable individually.
For now, this 2D case should use the manual configuration above.
Do you mean, when ScrollBehavior is stable, 2D case should work automatically too?
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.
Activity
[-]Scrollbar isAlwaysShown property is not shown when nested[/-][+]isAlwaysShown property doesn't work with nested Scrollbar[/+]TahaTesser commentedon Nov 13, 2020
Hi @Sangeetha-Raju1
Can you please provide your
flutter doctor -vyourflutter run --verboseThank you
Sangeetha-Raju1 commentedon Nov 16, 2020
Hi @TahaTesser ,
Please find the details,
flutter doctor -v
[√] Flutter (Channel master, 1.24.0-8.0.pre.49, on Microsoft Windows [Version 10.0.18363.1198], locale en-US) • Flutter version 1.24.0-8.0.pre.49 at C:\flutter • Framework revision 4019956fc8 (13 days ago), 2020-11-03 12:28:04 +0530 • Engine revision 3460519398 • Dart version 2.12.0 (build 2.12.0-3.0.dev) [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at C:\Users\SangeethaRaju\AppData\Local\Android\sdk • Platform android-30, build-tools 30.0.2 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted. [√] Android Studio (version 4.1.0) • Android Studio at C:\Program Files\Android\Android Studio • 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 1.8.0_242-release-1644-b01) [√] VS Code, 64-bit edition (version 1.51.0) • VS Code at C:\Program Files\Microsoft VS Code • Flutter extension version 3.16.0 [√] Connected device (1 available) • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator) • No issues found!logs
TahaTesser commentedon Nov 16, 2020
code sample
flutter doctor -v
[✓] Flutter (Channel stable, 1.22.4, on macOS 11.0.1 20B29 darwin-x64, locale en-GB) • Flutter version 1.22.4 at /Users/tahatesser/Code/flutter_stable • Framework revision 1aafb3a8b9 (3 days ago), 2020-11-13 09:59:28 -0800 • Engine revision 2c956a31c0 • Dart version 2.10.4 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/tahatesser/Code/sdk • Platform android-30, build-tools 30.0.2 • ANDROID_HOME = /Users/tahatesser/Code/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 12.2) • Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer • Xcode 12.2, Build version 12B45b • CocoaPods version 1.10.0 [!] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio.app/Contents ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) [✓] VS Code (version 1.51.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.16.0 [✓] Connected device (2 available) • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64 • Android 10 (API 29) • Taha’s iPad (mobile) • 00008020-000255113EE8402E • ios • iOS 14.2 ! Doctor found issues in 1 category.[✓] Flutter (Channel beta, 1.23.0-18.1.pre, on macOS 11.0.1 20B29 x86_64, locale en-GB) • Flutter version 1.23.0-18.1.pre at /Users/tahatesser/Code/flutter_beta • Framework revision 198df796aa (5 weeks ago), 2020-10-15 12:04:33 -0700 • Engine revision 1d12d82d9c • Dart version 2.11.0 (build 2.11.0-213.1.beta) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/tahatesser/Code/sdk • Platform android-30, build-tools 30.0.2 • ANDROID_HOME = /Users/tahatesser/Code/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 12.2) • Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer • Xcode 12.2, Build version 12B45b • CocoaPods version 1.10.0 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 4.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 1.8.0_242-release-1644-b3-6915495) [✓] VS Code (version 1.51.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.16.0 [✓] Connected device (4 available) • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64 • Android 10 (API 29) • Taha’s iPad (mobile) • 00008020-000255113EE8402E • ios • iOS 14.2 • Web Server (web) • web-server • web-javascript • Flutter Tools • Chrome (web) • chrome • web-javascript • Google Chrome 86.0.4240.198 • No issues found![✓] Flutter (Channel dev, 1.24.0-7.0.pre, on macOS 11.0.1 20B29 darwin-x64, locale en-GB) • Flutter version 1.24.0-7.0.pre at /Users/tahatesser/Code/flutter_dev • Framework revision a0860f6e87 (2 weeks ago), 2020-10-29 20:07:34 -0700 • Engine revision 073263e39d • Dart version 2.11.0 (build 2.11.0-260.0.dev) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/tahatesser/Code/sdk • Platform android-30, build-tools 30.0.2 • ANDROID_HOME = /Users/tahatesser/Code/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 12.2) • Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer • Xcode 12.2, Build version 12B45b • CocoaPods version 1.10.0 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 4.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 1.8.0_242-release-1644-b3-6915495) [✓] VS Code (version 1.51.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.16.0 [✓] Connected device (5 available) • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64 • Android 10 (API 29) • Taha’s iPad (mobile) • 00008020-000255113EE8402E • ios • iOS 14.2 • macOS (desktop) • macos • darwin-x64 • macOS 11.0.1 20B29 darwin-x64 • Web Server (web) • web-server • web-javascript • Flutter Tools • Chrome (web) • chrome • web-javascript • Google Chrome 86.0.4240.198 • No issues found![✓] Flutter (Channel master, 1.24.0-8.0.pre.252, on macOS 11.0.1 20B29 darwin-x64, locale en-GB) • Flutter version 1.24.0-8.0.pre.252 at /Users/tahatesser/Code/flutter_master • Framework revision bf2c9dfc05 (28 hours ago), 2020-11-14 22:38:02 -0500 • Engine revision 3e77d854a7 • Dart version 2.12.0 (build 2.12.0-45.0.dev) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/tahatesser/Code/sdk • Platform android-30, build-tools 30.0.2 • ANDROID_HOME = /Users/tahatesser/Code/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 12.2) • Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer • Xcode 12.2, Build version 12B45b • CocoaPods version 1.10.0 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 4.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 1.8.0_242-release-1644-b3-6915495) [✓] VS Code (version 1.51.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.16.0 [✓] Connected device (5 available) • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64 • Android 10 (API 29) • Taha’s iPad (mobile) • 00008020-000255113EE8402E • ios • iOS 14.2 • macOS (desktop) • macos • darwin-x64 • macOS 11.0.1 20B29 darwin-x64 • Web Server (web) • web-server • web-javascript • Flutter Tools • Chrome (web) • chrome • web-javascript • Google Chrome 86.0.4240.198 • No issues found!HansMuller commentedon Nov 16, 2020
CC @Piinks
xuanswe commentedon May 13, 2021
@TahaTesser This is exactly what I am facing.
In your example, the vertical scrollbar is nested in the horizontal one.
This vertical scrollbar is visible only when user scrolls horizontally to the right edge.
Beside the problem above, there's another issue when adding
LayoutBuilderto controlScrollbarwhich has aScrollControllerandisAlwaysShown: true.In the example above, when we expand the screen (web or desktop) from ex. 900dp width to ex. 1000dp width, an exception is thrown:
PS: the example code is modified from https://stackoverflow.com/a/67507025/8228301
Piinks commentedon May 14, 2021
@nguyenxndaidev can you please file a separate issue for this with a reproduction? This does not appear to be the same as this issue.
Piinks commentedon May 14, 2021
I believe this has been resolved, running today on the latest master, both scrollbars are visible. Although in the current configuration, one of them is out of view until you scroll far enough to the other edge to see it. This can be fixed by rearranging the widgets and setting the notification predicate for one of the scrollbars.
Here is a simplified version of the original code:
Code Before
If we move the vertical scrollbar above the horizontal scroll view, then we can see both scrollbars above the 2D scroll view.
Moving our vertical Scrollbar further away from the vertical scroll view like this changes the ScrollNotification depth, but @xu-baolin made it possible to configure this in #74104 with Scrollbar.notificationPredicate.
So the updated code looks like this:
Code After
And it looks like this! :)
2D_scrollbar.mov
I am going to close this as it appears to be working properly, but feel free to re-open if we need to investigate further! Thank you!
xuanswe commentedon May 14, 2021
@Piinks Here you are :-) #82573
xuanswe commentedon May 14, 2021
@Piinks Could you please give the code which works automatically on desktop? Will it also work automatically on browser?
Piinks commentedon May 14, 2021
The scrollbars automatically applied by ScrollBehavior has not reached the stable branch yet, but you can read all about how they work and how you can configure them here: https://flutter.dev/docs/release/breaking-changes/default-desktop-scrollbars
I do not think that feature will work for this case though, as the Scrollbars are applied to each scrollable individually. That would result in the situation above where one of them was contained in the scrollable and could not be seen until you scrolled to the other edge. For now, this 2D case should use the manual configuration above.
xuanswe commentedon May 14, 2021
Thanks @Piinks for the link, I will check it later.
Do you mean, when
ScrollBehavioris stable, 2D case should work automatically too?xuanswe commentedon May 14, 2021
I modified your code a bit to move Scaffold to inside Scrollbar. And it works like a charm on stable channel 😄
github-actions commentedon Aug 1, 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.