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
3d94a014
Unverified
Commit
3d94a014
authored
Aug 17, 2022
by
xubaolin
Committed by
GitHub
Aug 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scrollbar respect the NeverScrollableScrollPhysics physics (#109609)
parent
143a09d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
scrollbar.dart
packages/flutter/lib/src/widgets/scrollbar.dart
+9
-0
scrollbar_test.dart
packages/flutter/test/widgets/scrollbar_test.dart
+42
-0
No files found.
packages/flutter/lib/src/widgets/scrollbar.dart
View file @
3d94a014
...
...
@@ -1772,6 +1772,10 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
@mustCallSuper
void
handleThumbPressUpdate
(
Offset
localPosition
)
{
assert
(
_debugCheckHasValidScrollPosition
());
final
ScrollPosition
position
=
_currentController
!.
position
;
if
(!
position
.
physics
.
shouldAcceptUserOffset
(
position
))
{
return
;
}
final
Axis
?
direction
=
getScrollbarDirection
();
if
(
direction
==
null
)
{
return
;
...
...
@@ -1799,6 +1803,11 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
assert
(
_debugCheckHasValidScrollPosition
());
_currentController
=
widget
.
controller
??
PrimaryScrollController
.
of
(
context
);
final
ScrollPosition
position
=
_currentController
!.
position
;
if
(!
position
.
physics
.
shouldAcceptUserOffset
(
position
))
{
return
;
}
double
scrollIncrement
;
// Is an increment calculator available?
final
ScrollIncrementCalculator
?
calculator
=
Scrollable
.
of
(
...
...
packages/flutter/test/widgets/scrollbar_test.dart
View file @
3d94a014
...
...
@@ -2675,4 +2675,46 @@ void main() {
..
rect
(
rect:
const
Rect
.
fromLTRB
(
694.0
,
100.0
,
700.0
,
121.0
))
// thumb
);
// thumb
});
testWidgets
(
'Scrollbar respect the NeverScrollableScrollPhysics physics'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
scrollController
=
ScrollController
();
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
PrimaryScrollController
(
controller:
scrollController
,
child:
RawScrollbar
(
thumbVisibility:
true
,
controller:
scrollController
,
child:
const
SingleChildScrollView
(
physics:
NeverScrollableScrollPhysics
(),
child:
SizedBox
(
width:
4000.0
,
height:
4000.0
),
),
),
),
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
scrollController
.
offset
,
0.0
);
// Drag the thumb down to scroll down.
const
double
scrollAmount
=
10.0
;
final
TestGesture
dragScrollbarGesture
=
await
tester
.
startGesture
(
const
Offset
(
797.0
,
45.0
));
await
tester
.
pumpAndSettle
();
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
scrollAmount
));
await
tester
.
pumpAndSettle
();
await
dragScrollbarGesture
.
up
();
await
tester
.
pumpAndSettle
();
expect
(
scrollController
.
offset
,
0.0
);
// Tap on the track area below the thumb.
await
tester
.
tapAt
(
const
Offset
(
797.0
,
550.0
));
await
tester
.
pumpAndSettle
();
expect
(
scrollController
.
offset
,
0.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