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
79146fd0
Unverified
Commit
79146fd0
authored
Aug 06, 2020
by
Kate Lovett
Committed by
GitHub
Aug 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix SliverList scrollOffsetCorrection 0 case (#62615)
parent
4680ff3a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
6 deletions
+37
-6
sliver_list.dart
packages/flutter/lib/src/rendering/sliver_list.dart
+12
-6
slivers_test.dart
packages/flutter/test/widgets/slivers_test.dart
+25
-0
No files found.
packages/flutter/lib/src/rendering/sliver_list.dart
View file @
79146fd0
...
...
@@ -169,22 +169,28 @@ class RenderSliverList extends RenderSliverMultiBoxAdaptor {
// If the scroll offset is at zero, we should make sure we are
// actually at the beginning of the list.
if
(
scrollOffset
<
precisionErrorTolerance
)
{
if
(
indexOf
(
firstChild
)
>
0
)
{
// We iterate from the firstChild in case the leading child has a 0 paint
// extent.
while
(
indexOf
(
firstChild
)
>
0
)
{
final
double
earliestScrollOffset
=
childScrollOffset
(
firstChild
);
// We correct one child at a time. If there are more children before
// the earliestUsefulChild, we will correct it once the scroll offset
// reach zero again.
// reach
es
zero again.
earliestUsefulChild
=
insertAndLayoutLeadingChild
(
childConstraints
,
parentUsesSize:
true
);
assert
(
earliestUsefulChild
!=
null
);
final
double
firstChildScrollOffset
=
earliestScrollOffset
-
paintExtentOf
(
firstChild
);
final
SliverMultiBoxAdaptorParentData
childParentData
=
firstChild
.
parentData
as
SliverMultiBoxAdaptorParentData
;
childParentData
.
layoutOffset
=
0.0
;
// We only need to correct if the leading child actually has a
// paint extent.
if
(
firstChildScrollOffset
<
-
precisionErrorTolerance
)
{
geometry
=
SliverGeometry
(
scrollOffsetCorrection:
-
firstChildScrollOffset
,
);
final
SliverMultiBoxAdaptorParentData
childParentData
=
firstChild
.
parentData
as
SliverMultiBoxAdaptorParentData
;
childParentData
.
layoutOffset
=
0.0
;
return
;
}
}
}
// At this point, earliestUsefulChild is the first child, and is a child
// whose scrollOffset is at or before the scrollOffset, and
...
...
packages/flutter/test/widgets/slivers_test.dart
View file @
79146fd0
...
...
@@ -814,6 +814,31 @@ void main() {
expect
(
events
,
equals
(<
String
>[
'tap'
]));
});
});
testWidgets
(
'SliverList handles 0 scrollOffsetCorrection'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/62198
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
CustomScrollView
(
physics:
const
BouncingScrollPhysics
(
parent:
AlwaysScrollableScrollPhysics
()),
slivers:
<
Widget
>[
SliverList
(
delegate:
SliverChildListDelegate
(
const
<
Widget
>[
SizedBox
.
shrink
(),
Text
(
'index 1'
),
Text
(
'index 2'
),
]
),
),
],
)
),
));
await
tester
.
fling
(
find
.
byType
(
Scrollable
),
const
Offset
(
0.0
,
-
500.0
),
10000.0
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
takeException
(),
isNull
);
});
}
bool
isRight
(
Offset
a
,
Offset
b
)
=>
b
.
dx
>
a
.
dx
;
...
...
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