Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a4b724d9
Unverified
Commit
a4b724d9
authored
Aug 16, 2021
by
xubaolin
Committed by
GitHub
Aug 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a scrollbar updating bug (#88152)
parent
c49eba6c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
2 deletions
+44
-2
scroll_notification.dart
packages/flutter/lib/src/widgets/scroll_notification.dart
+6
-1
scrollbar.dart
packages/flutter/lib/src/widgets/scrollbar.dart
+5
-1
scrollbar_test.dart
packages/flutter/test/widgets/scrollbar_test.dart
+33
-0
No files found.
packages/flutter/lib/src/widgets/scroll_notification.dart
View file @
a4b724d9
...
...
@@ -144,7 +144,12 @@ class ScrollUpdateNotification extends ScrollNotification {
required
BuildContext
context
,
this
.
dragDetails
,
this
.
scrollDelta
,
})
:
super
(
metrics:
metrics
,
context:
context
);
int
?
depth
,
})
:
super
(
metrics:
metrics
,
context:
context
)
{
if
(
depth
!=
null
)
{
_depth
=
depth
;
}
}
/// If the [Scrollable] changed its scroll position because of a drag, the
/// details about that drag update.
...
...
packages/flutter/lib/src/widgets/scrollbar.dart
View file @
a4b724d9
...
...
@@ -1550,7 +1550,11 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
}
bool
_handleScrollMetricsNotification
(
ScrollMetricsNotification
notification
)
{
if
(!
widget
.
notificationPredicate
(
ScrollUpdateNotification
(
metrics:
notification
.
metrics
,
context:
notification
.
context
)))
if
(!
widget
.
notificationPredicate
(
ScrollUpdateNotification
(
metrics:
notification
.
metrics
,
context:
notification
.
context
,
depth:
notification
.
depth
,
)))
return
false
;
if
(
showScrollbar
)
{
...
...
packages/flutter/test/widgets/scrollbar_test.dart
View file @
a4b724d9
...
...
@@ -1708,4 +1708,37 @@ void main() {
),
);
});
testWidgets
(
'notificationPredicate depth test.'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
scrollController
=
ScrollController
();
final
List
<
int
>
depths
=
<
int
>[];
Widget
buildFrame
()
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
RawScrollbar
(
notificationPredicate:
(
ScrollNotification
notification
)
{
depths
.
add
(
notification
.
depth
);
return
notification
.
depth
==
0
;
},
controller:
scrollController
,
isAlwaysShown:
true
,
child:
SingleChildScrollView
(
controller:
scrollController
,
child:
const
SingleChildScrollView
(),
),
),
),
);
}
await
tester
.
pumpWidget
(
buildFrame
());
await
tester
.
pumpAndSettle
();
// `notificationPredicate` should be called twice with different `depth`
// because there are two scrollable widgets.
expect
(
depths
.
length
,
2
);
expect
(
depths
[
0
],
1
);
expect
(
depths
[
1
],
0
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment