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
6ab3abfb
Unverified
Commit
6ab3abfb
authored
Jun 15, 2018
by
Michael Goderbauer
Committed by
GitHub
Jun 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix clipping for SliverLists (#18410)
parent
40900782
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
2 deletions
+118
-2
sliver_fixed_extent_list.dart
...s/flutter/lib/src/rendering/sliver_fixed_extent_list.dart
+4
-1
sliver_list.dart
packages/flutter/lib/src/rendering/sliver_list.dart
+2
-1
list_view_test.dart
packages/flutter/test/widgets/list_view_test.dart
+112
-0
No files found.
packages/flutter/lib/src/rendering/sliver_fixed_extent_list.dart
View file @
6ab3abfb
...
...
@@ -248,13 +248,16 @@ abstract class RenderSliverFixedExtentBoxAdaptor extends RenderSliverMultiBoxAda
to:
trailingScrollOffset
,
);
final
double
targetEndScrollOffsetForPaint
=
constraints
.
scrollOffset
+
constraints
.
remainingPaintExtent
;
final
int
targetLastIndexForPaint
=
targetEndScrollOffsetForPaint
.
isFinite
?
getMaxChildIndexForScrollOffset
(
targetEndScrollOffsetForPaint
,
itemExtent
)
:
null
;
geometry
=
new
SliverGeometry
(
scrollExtent:
estimatedMaxScrollOffset
,
paintExtent:
paintExtent
,
cacheExtent:
cacheExtent
,
maxPaintExtent:
estimatedMaxScrollOffset
,
// Conservative to avoid flickering away the clip during scroll.
hasVisualOverflow:
(
targetLastIndex
!=
null
&&
lastIndex
>=
targetLastIndex
)
hasVisualOverflow:
(
targetLastIndex
ForPaint
!=
null
&&
lastIndex
>=
targetLastIndexForPaint
)
||
constraints
.
scrollOffset
>
0.0
,
);
...
...
packages/flutter/lib/src/rendering/sliver_list.dart
View file @
6ab3abfb
...
...
@@ -274,13 +274,14 @@ class RenderSliverList extends RenderSliverMultiBoxAdaptor {
from:
childScrollOffset
(
firstChild
),
to:
endScrollOffset
,
);
final
double
targetEndScrollOffsetForPaint
=
constraints
.
scrollOffset
+
constraints
.
remainingPaintExtent
;
geometry
=
new
SliverGeometry
(
scrollExtent:
estimatedMaxScrollOffset
,
paintExtent:
paintExtent
,
cacheExtent:
cacheExtent
,
maxPaintExtent:
estimatedMaxScrollOffset
,
// Conservative to avoid flickering away the clip during scroll.
hasVisualOverflow:
endScrollOffset
>
targetEndScrollOffset
||
constraints
.
scrollOffset
>
0.0
,
hasVisualOverflow:
endScrollOffset
>
targetEndScrollOffset
ForPaint
||
constraints
.
scrollOffset
>
0.0
,
);
// We may have started the layout while scrolled to the end, which would not
...
...
packages/flutter/test/widgets/list_view_test.dart
View file @
6ab3abfb
...
...
@@ -5,6 +5,8 @@
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'../rendering/mock_canvas.dart'
;
class
TestSliverChildListDelegate
extends
SliverChildListDelegate
{
TestSliverChildListDelegate
(
List
<
Widget
>
children
)
:
super
(
children
);
...
...
@@ -293,4 +295,114 @@ void main() {
// Leave left/right padding as is for children.
expect
(
innerMediaQueryPadding
,
const
EdgeInsets
.
symmetric
(
horizontal:
30.0
));
});
testWidgets
(
'ListView clips if overflow is smaller than cacheExtent'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/17426.
await
tester
.
pumpWidget
(
new
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
new
Center
(
child:
new
Container
(
height:
200.0
,
child:
new
ListView
(
cacheExtent:
500.0
,
children:
<
Widget
>[
new
Container
(
height:
90.0
,
),
new
Container
(
height:
110.0
,
),
new
Container
(
height:
80.0
,
),
],
),
),
),
),
);
expect
(
find
.
byType
(
Viewport
),
paints
..
clipRect
());
});
testWidgets
(
'ListView does not clips if no overflow'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
new
Center
(
child:
new
Container
(
height:
200.0
,
child:
new
ListView
(
cacheExtent:
500.0
,
children:
<
Widget
>[
new
Container
(
height:
100.0
,
),
],
),
),
),
),
);
expect
(
find
.
byType
(
Viewport
),
isNot
(
paints
..
clipRect
()));
});
testWidgets
(
'ListView (fixed extent) clips if overflow is smaller than cacheExtent'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/17426.
await
tester
.
pumpWidget
(
new
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
new
Center
(
child:
new
Container
(
height:
200.0
,
child:
new
ListView
(
itemExtent:
100.0
,
cacheExtent:
500.0
,
children:
<
Widget
>[
new
Container
(
height:
100.0
,
),
new
Container
(
height:
100.0
,
),
new
Container
(
height:
100.0
,
),
],
),
),
),
),
);
expect
(
find
.
byType
(
Viewport
),
paints
..
clipRect
());
});
testWidgets
(
'ListView (fixed extent) does not clips if no overflow'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
new
Center
(
child:
new
Container
(
height:
200.0
,
child:
new
ListView
(
itemExtent:
100.0
,
cacheExtent:
500.0
,
children:
<
Widget
>[
new
Container
(
height:
100.0
,
),
],
),
),
),
),
);
expect
(
find
.
byType
(
Viewport
),
isNot
(
paints
..
clipRect
()));
});
}
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