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
ba92cbed
Unverified
Commit
ba92cbed
authored
Aug 10, 2020
by
xubaolin
Committed by
GitHub
Aug 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix SingleChildScrollView clip bug (#63054)
parent
94319c7a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
1 deletion
+67
-1
single_child_scroll_view.dart
...ges/flutter/lib/src/widgets/single_child_scroll_view.dart
+4
-1
single_child_scroll_view_test.dart
...s/flutter/test/widgets/single_child_scroll_view_test.dart
+63
-0
No files found.
packages/flutter/lib/src/widgets/single_child_scroll_view.dart
View file @
ba92cbed
...
...
@@ -568,7 +568,10 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix
bool
_shouldClipAtPaintOffset
(
Offset
paintOffset
)
{
assert
(
child
!=
null
);
return
paintOffset
<
Offset
.
zero
||
!(
Offset
.
zero
&
size
).
contains
((
paintOffset
&
child
.
size
).
bottomRight
);
return
paintOffset
.
dx
<
0
||
paintOffset
.
dy
<
0
||
paintOffset
.
dx
+
child
.
size
.
width
>
size
.
width
||
paintOffset
.
dy
+
child
.
size
.
height
>
size
.
height
;
}
@override
...
...
packages/flutter/test/widgets/single_child_scroll_view_test.dart
View file @
ba92cbed
...
...
@@ -40,6 +40,69 @@ class TestScrollController extends ScrollController {
}
void
main
(
)
{
testWidgets
(
'SingleChildScrollView overflow and clipRect test'
,
(
WidgetTester
tester
)
async
{
// the test widowSize is Size(800.0, 600.0)
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
SingleChildScrollView
(
scrollDirection:
Axis
.
vertical
,
child:
Container
(
height:
600.0
,)
)
)
);
// 1st, check that the render object has received the default clip behavior.
final
dynamic
renderObject
=
tester
.
allRenderObjects
.
where
((
RenderObject
o
)
=>
o
.
runtimeType
.
toString
()
==
'_RenderSingleChildViewport'
).
first
;
expect
(
renderObject
.
clipBehavior
,
equals
(
Clip
.
hardEdge
));
// 2nd, height == widow.height test: check that the painting context does not call pushClipRect .
TestClipPaintingContext
context
=
TestClipPaintingContext
();
renderObject
.
paint
(
context
,
Offset
.
zero
);
expect
(
context
.
clipBehavior
,
equals
(
Clip
.
none
));
// 3rd, height overflow test: check that the painting context call pushClipRect.
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
SingleChildScrollView
(
scrollDirection:
Axis
.
vertical
,
child:
Container
(
height:
600.1
,)
)
)
);
renderObject
.
paint
(
context
,
Offset
.
zero
);
expect
(
context
.
clipBehavior
,
equals
(
Clip
.
hardEdge
));
// 4th, width == widow.width test: check that the painting context do not call pushClipRect.
context
=
TestClipPaintingContext
();
expect
(
context
.
clipBehavior
,
equals
(
Clip
.
none
));
// initial value
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
SingleChildScrollView
(
scrollDirection:
Axis
.
horizontal
,
child:
Container
(
width:
800.0
,)
)
)
);
renderObject
.
paint
(
context
,
Offset
.
zero
);
expect
(
context
.
clipBehavior
,
equals
(
Clip
.
none
));
// 5th, width overflow test: check that the painting context call pushClipRect.
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
SingleChildScrollView
(
scrollDirection:
Axis
.
horizontal
,
child:
Container
(
width:
800.1
,)
)
)
);
renderObject
.
paint
(
context
,
Offset
.
zero
);
expect
(
context
.
clipBehavior
,
equals
(
Clip
.
hardEdge
));
});
testWidgets
(
'SingleChildScrollView respects clipBehavior'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
SingleChildScrollView
(
child:
Container
(
height:
2000.0
)));
...
...
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