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
806fb93c
Unverified
Commit
806fb93c
authored
Oct 24, 2022
by
Kate Lovett
Committed by
GitHub
Oct 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ScrollPosition.isScrollingNotifier.value for pointer scrolling (#113972)
parent
694b2535
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
3 deletions
+34
-3
scroll_position.dart
packages/flutter/lib/src/widgets/scroll_position.dart
+0
-2
scroll_position_with_single_context.dart
.../lib/src/widgets/scroll_position_with_single_context.dart
+3
-1
scroll_controller_test.dart
packages/flutter/test/widgets/scroll_controller_test.dart
+31
-0
No files found.
packages/flutter/lib/src/widgets/scroll_position.dart
View file @
806fb93c
...
@@ -810,8 +810,6 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
...
@@ -810,8 +810,6 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
///
///
/// This method is very similar to [jumpTo], but [pointerScroll] will
/// This method is very similar to [jumpTo], but [pointerScroll] will
/// update the [ScrollDirection].
/// update the [ScrollDirection].
///
// TODO(YeungKC): Support trackpad scroll, https://github.com/flutter/flutter/issues/23604.
void
pointerScroll
(
double
delta
);
void
pointerScroll
(
double
delta
);
/// Calls [jumpTo] if duration is null or [Duration.zero], otherwise
/// Calls [jumpTo] if duration is null or [Duration.zero], otherwise
...
...
packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart
View file @
806fb93c
...
@@ -222,8 +222,10 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc
...
@@ -222,8 +222,10 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc
-
delta
>
0.0
?
ScrollDirection
.
forward
:
ScrollDirection
.
reverse
,
-
delta
>
0.0
?
ScrollDirection
.
forward
:
ScrollDirection
.
reverse
,
);
);
final
double
oldPixels
=
pixels
;
final
double
oldPixels
=
pixels
;
forcePixels
(
targetPixels
);
// Set the notifier before calling force pixels.
// This is set to false again after going ballistic below.
isScrollingNotifier
.
value
=
true
;
isScrollingNotifier
.
value
=
true
;
forcePixels
(
targetPixels
);
didStartScroll
();
didStartScroll
();
didUpdateScrollPositionBy
(
pixels
-
oldPixels
);
didUpdateScrollPositionBy
(
pixels
-
oldPixels
);
didEndScroll
();
didEndScroll
();
...
...
packages/flutter/test/widgets/scroll_controller_test.dart
View file @
806fb93c
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
import
'dart:ui'
as
ui
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -362,4 +364,33 @@ void main() {
...
@@ -362,4 +364,33 @@ void main() {
expect
(
tester
.
getTopLeft
(
find
.
widgetWithText
(
SizedBox
,
'Item 1'
)),
Offset
.
zero
);
expect
(
tester
.
getTopLeft
(
find
.
widgetWithText
(
SizedBox
,
'Item 1'
)),
Offset
.
zero
);
});
});
testWidgets
(
'isScrollingNotifier works with pointer scroll'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
(
ScrollController
controller
)
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
ListView
(
controller:
controller
,
children:
List
<
Widget
>.
generate
(
50
,
(
int
index
)
{
return
SizedBox
(
height:
100.0
,
child:
Text
(
'Item
$index
'
));
}).
toList
(),
),
);
}
bool
isScrolling
=
false
;
final
ScrollController
controller
=
ScrollController
();
controller
.
addListener
((){
isScrolling
=
controller
.
position
.
isScrollingNotifier
.
value
;
});
await
tester
.
pumpWidget
(
buildFrame
(
controller
));
final
Offset
scrollEventLocation
=
tester
.
getCenter
(
find
.
byType
(
ListView
));
final
TestPointer
testPointer
=
TestPointer
(
1
,
ui
.
PointerDeviceKind
.
mouse
);
// Create a hover event so that |testPointer| has a location when generating the scroll.
testPointer
.
hover
(
scrollEventLocation
);
await
tester
.
sendEventToBinding
(
testPointer
.
scroll
(
const
Offset
(
0.0
,
300.0
)));
// When the listener was notified, the value of the isScrollingNotifier
// should have been true
expect
(
isScrolling
,
isTrue
);
});
}
}
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