Repository navigation
Improve the ScrollBar behavior when nested - #71843
Conversation
Piinks
left a comment
There was a problem hiding this comment.
Hi @xu-baolin thank you for another quality contribution!
I'm currently working on a large change to scrollbars, let's coordinate to land this once that is in since the _handleScrollNotification will be in a new class.
Also, can you ping me on discord when you have a chance? (@Piinks https://github.com/flutter/flutter/wiki/Chat)
There was a problem hiding this comment.
We should make this configurable, some folks may expect their nested scrollbars to show up. This would break them.
I think this is one such case #70380
|
Reference: #71664 |
Good job 👍 |
|
Triage update: Waiting on #71664 |
6708f05 to
b6f2e5e
Compare
#71664 There is another problem hidden here. When the cross axis of the scrollbar is also a scrollable widget, the So for this situation, what do you think is the expected result? Sample code(only one scrollbar can reproduce)import 'package:flutter/material.dart';
main() => runApp(MaterialApp(home: MyApp()));
class MyApp extends StatefulWidget {
@override
MyAppState createState() => MyAppState();
}
class MyAppState extends State<MyApp> {
ScrollController verticalController = ScrollController();
ScrollController horizontalController = ScrollController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('ScrollBar')),
body: Container(
child: SingleChildScrollView(
controller: horizontalController,
scrollDirection: Axis.horizontal,
physics: const AlwaysScrollableScrollPhysics(),
child: Scrollbar(
controller: verticalController,
isAlwaysShown: true,
child: SingleChildScrollView(
controller: verticalController,
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
children: [
Row(
children: [
Container(
color: Colors.yellow,
height: 1000,
width: 1000,
),
],
),
],
),
),
),
),
),
);
}
} |
|
I am not familiar with that use case, but we should file a separate bug so we can investigate. I have a few more follow up changes I'm going to make based on some early feedback on scrollbars, I'll share when I have a PR. :) |
|
Hi @xu-baolin |
OK. |
4f02c81 to
5ad02aa
Compare
|
I am ready for review now! :) |
83e9772 to
ed03b70
Compare
Piinks
left a comment
There was a problem hiding this comment.
This looks really great - and it fixes a bunch of issues! Well done! I think we just need to touch up the docs and this is ready. :)
| /// A check that specifies whether a [ScrollNotification] should be | ||
| /// handled by this widget. | ||
| /// | ||
| /// By default, checks whether `notification.depth == 0`. Set it to something | ||
| /// else for more complicated layouts. |
There was a problem hiding this comment.
Let's make this documentation a little clearer. Often I look to the bugs I am fixing that describe the problem to help write the docs.
Mentioning how this can be helpful when the scrollbar is wrapped around multiple or nested scroll views would be a good idea, since that appears to be the most common issue you're solving here.
This reverts commit 54ef030.

Description
This change let the
ScrollBarwidget ignore theScrollNotificationmessage that depth not equal to zero.This change can resolve the situation that scrolls the inner scrollable widget cause the outer scrollbar paint incorrectly such as #66444.
@Piinks Hi, please review, thanks.
Related Issues
Related #66444
Fixes #36474
Fixes #70771
Fixes #73697
Tests
I added the following tests:
See files.