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
8e8f6185
Unverified
Commit
8e8f6185
authored
Oct 22, 2020
by
Kate Lovett
Committed by
GitHub
Oct 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix overscroll edge case that puts NestedScrollViews out of sync (#68644)
parent
c5c2b24a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
1 deletion
+58
-1
nested_scroll_view.dart
packages/flutter/lib/src/widgets/nested_scroll_view.dart
+3
-1
nested_scroll_view_test.dart
packages/flutter/test/widgets/nested_scroll_view_test.dart
+55
-0
No files found.
packages/flutter/lib/src/widgets/nested_scroll_view.dart
View file @
8e8f6185
...
...
@@ -1343,7 +1343,9 @@ class _NestedScrollPosition extends ScrollPosition implements ScrollActivityDele
// The logic for max is equivalent but on the other side.
final
double
max
=
delta
>
0.0
?
double
.
infinity
:
math
.
max
(
maxScrollExtent
,
pixels
);
// If pixels < 0.0, then we are currently in overscroll. The max should be
// 0.0, representing the end of the overscrolled portion.
:
pixels
<
0.0
?
0.0
:
math
.
max
(
maxScrollExtent
,
pixels
);
final
double
oldPixels
=
pixels
;
final
double
newPixels
=
(
pixels
-
delta
).
clamp
(
min
,
max
);
final
double
clampedDelta
=
newPixels
-
pixels
;
...
...
packages/flutter/test/widgets/nested_scroll_view_test.dart
View file @
8e8f6185
...
...
@@ -1906,6 +1906,61 @@ void main() {
expect
(
tester
.
getCenter
(
find
.
text
(
'Item 49'
)).
dy
,
equals
(
585.0
));
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
}));
});
// Regression test for https://github.com/flutter/flutter/issues/63978
testWidgets
(
'Inner _NestedScrollPosition.applyClampedDragUpdate correctly calculates range when in overscroll'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
NestedScrollViewState
>
nestedScrollView
=
GlobalKey
();
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
NestedScrollView
(
key:
nestedScrollView
,
headerSliverBuilder:
(
BuildContext
context
,
bool
boxIsScrolled
)
{
return
<
Widget
>[
const
SliverAppBar
(
expandedHeight:
200
,
title:
Text
(
'Test'
),
)
];
},
body:
ListView
.
builder
(
itemExtent:
100.0
,
itemBuilder:
(
BuildContext
context
,
int
index
)
=>
Container
(
padding:
const
EdgeInsets
.
all
(
10.0
),
child:
Material
(
color:
index
.
isEven
?
Colors
.
cyan
:
Colors
.
deepOrange
,
child:
Center
(
child:
Text
(
index
.
toString
()),
),
),
),
),
),
),
));
expect
(
nestedScrollView
.
currentState
!.
outerController
.
position
.
pixels
,
0.0
);
expect
(
nestedScrollView
.
currentState
!.
innerController
.
position
.
pixels
,
0.0
);
expect
(
nestedScrollView
.
currentState
!.
outerController
.
position
.
maxScrollExtent
,
200.0
);
final
Offset
point
=
tester
.
getCenter
(
find
.
text
(
'1'
));
// Drag slightly into overscroll in the inner position.
final
TestGesture
gesture
=
await
tester
.
startGesture
(
point
);
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
5.0
));
await
tester
.
pump
();
expect
(
nestedScrollView
.
currentState
!.
outerController
.
position
.
pixels
,
0.0
);
expect
(
nestedScrollView
.
currentState
!.
innerController
.
position
.
pixels
,
-
5.0
);
// Move by a much larger delta than the amount of over scroll, in a very
// short period of time.
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
500.0
));
await
tester
.
pump
();
// The overscrolled inner position should have closed, then passed the
// correct remaining delta to the outer position, and finally any remainder
// back to the inner position.
expect
(
nestedScrollView
.
currentState
!.
outerController
.
position
.
pixels
,
nestedScrollView
.
currentState
!.
outerController
.
position
.
maxScrollExtent
,
);
expect
(
nestedScrollView
.
currentState
!.
innerController
.
position
.
pixels
,
295.0
);
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
}
class
TestHeader
extends
SliverPersistentHeaderDelegate
{
...
...
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