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
02bf594f
Unverified
Commit
02bf594f
authored
Jan 08, 2022
by
xubaolin
Committed by
GitHub
Jan 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a scrollbar bug (#95894)
parent
1bd8b580
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
1 deletion
+82
-1
scrollbar.dart
packages/flutter/lib/src/widgets/scrollbar.dart
+1
-1
scrollbar_test.dart
packages/flutter/test/widgets/scrollbar_test.dart
+81
-0
No files found.
packages/flutter/lib/src/widgets/scrollbar.dart
View file @
02bf594f
...
...
@@ -1432,7 +1432,7 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
windows
:
newPosition
=
newPosition
.
clamp
(
0.0
,
position
.
maxScrollExtent
);
newPosition
=
newPosition
.
clamp
(
position
.
minScrollExtent
,
position
.
maxScrollExtent
);
break
;
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
android
:
...
...
packages/flutter/test/widgets/scrollbar_test.dart
View file @
02bf594f
...
...
@@ -2075,6 +2075,87 @@ void main() {
await
tester
.
pumpAndSettle
();
});
testWidgets
(
'Scrollbar thumb can be dragged when the scrollable widget has a negative minScrollExtent'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/95840
final
ScrollController
scrollController
=
ScrollController
();
final
UniqueKey
uniqueKey
=
UniqueKey
();
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
ScrollConfiguration
(
behavior:
const
ScrollBehavior
().
copyWith
(
scrollbars:
false
,
),
child:
PrimaryScrollController
(
controller:
scrollController
,
child:
RawScrollbar
(
isAlwaysShown:
true
,
controller:
scrollController
,
child:
CustomScrollView
(
center:
uniqueKey
,
slivers:
<
Widget
>[
SliverToBoxAdapter
(
child:
Container
(
height:
600.0
,
),
),
SliverToBoxAdapter
(
key:
uniqueKey
,
child:
Container
(
height:
600.0
,
),
),
SliverToBoxAdapter
(
child:
Container
(
height:
600.0
,
),
),
],
),
),
),
),
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
scrollController
.
offset
,
0.0
);
expect
(
find
.
byType
(
RawScrollbar
),
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
0.0
,
800.0
,
600.0
))
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
200.0
,
800.0
,
400.0
),
color:
const
Color
(
0x66BCBCBC
),
),
);
// Drag the thumb up to scroll up.
const
double
scrollAmount
=
-
10.0
;
final
TestGesture
dragScrollbarGesture
=
await
tester
.
startGesture
(
const
Offset
(
797.0
,
300.0
));
await
tester
.
pumpAndSettle
();
await
dragScrollbarGesture
.
moveBy
(
const
Offset
(
0.0
,
scrollAmount
));
await
tester
.
pumpAndSettle
();
await
dragScrollbarGesture
.
up
();
await
tester
.
pumpAndSettle
();
// The view has scrolled more than it would have by a swipe gesture of the
// same distance.
expect
(
scrollController
.
offset
,
lessThan
(
scrollAmount
*
2
));
expect
(
find
.
byType
(
RawScrollbar
),
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
0.0
,
800.0
,
600.0
))
..
rect
(
rect:
const
Rect
.
fromLTRB
(
794.0
,
190.0
,
800.0
,
390.0
),
color:
const
Color
(
0x66BCBCBC
),
),
);
},
variant:
TargetPlatformVariant
.
all
());
test
(
'ScrollbarPainter.shouldRepaint returns true when any of the properties changes'
,
()
{
ScrollbarPainter
createPainter
({
Color
color
=
const
Color
(
0xFF000000
),
...
...
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