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
a783e422
Unverified
Commit
a783e422
authored
Jun 16, 2022
by
Kate Lovett
Committed by
GitHub
Jun 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix SliverPadding geometry (#106071)
parent
f67d9b75
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
2 deletions
+41
-2
sliver_padding.dart
packages/flutter/lib/src/rendering/sliver_padding.dart
+12
-1
slivers_padding_test.dart
packages/flutter/test/widgets/slivers_padding_test.dart
+29
-1
No files found.
packages/flutter/lib/src/rendering/sliver_padding.dart
View file @
a783e422
...
...
@@ -119,10 +119,21 @@ abstract class RenderSliverEdgeInsetsPadding extends RenderSliver with RenderObj
final
double
mainAxisPadding
=
this
.
mainAxisPadding
;
final
double
crossAxisPadding
=
this
.
crossAxisPadding
;
if
(
child
==
null
)
{
final
double
paintExtent
=
calculatePaintOffset
(
constraints
,
from:
0.0
,
to:
mainAxisPadding
,
);
final
double
cacheExtent
=
calculateCacheOffset
(
constraints
,
from:
0.0
,
to:
mainAxisPadding
,
);
geometry
=
SliverGeometry
(
scrollExtent:
mainAxisPadding
,
paintExtent:
math
.
min
(
mainAxisPadding
,
constraints
.
remainingPaintExtent
),
paintExtent:
math
.
min
(
paintExtent
,
constraints
.
remainingPaintExtent
),
maxPaintExtent:
mainAxisPadding
,
cacheExtent:
cacheExtent
,
);
return
;
}
...
...
packages/flutter/test/widgets/slivers_padding_test.dart
View file @
a783e422
...
...
@@ -271,6 +271,34 @@ void main() {
expect
(
tester
.
renderObject
<
RenderBox
>(
find
.
text
(
'x'
)).
localToGlobal
(
Offset
.
zero
),
const
Offset
(
0.0
,
200.0
));
});
testWidgets
(
'SliverPadding with no child reports correct geometry as scroll offset changes'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/64506
final
ScrollController
controller
=
ScrollController
();
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
CustomScrollView
(
controller:
controller
,
slivers:
const
<
Widget
>[
SliverPadding
(
padding:
EdgeInsets
.
all
(
100.0
)),
SliverToBoxAdapter
(
child:
SizedBox
(
width:
400.0
,
height:
400.0
,
child:
Text
(
'x'
))),
],
),
),
);
expect
(
tester
.
renderObject
<
RenderBox
>(
find
.
text
(
'x'
)).
localToGlobal
(
Offset
.
zero
),
const
Offset
(
0.0
,
200.0
));
expect
(
tester
.
renderObject
<
RenderSliverPadding
>(
find
.
byType
(
SliverPadding
)).
geometry
!.
paintExtent
,
200.0
,
);
controller
.
jumpTo
(
50.0
);
await
tester
.
pump
();
expect
(
tester
.
renderObject
<
RenderSliverPadding
>(
find
.
byType
(
SliverPadding
)).
geometry
!.
paintExtent
,
150.0
,
);
});
testWidgets
(
'Viewport+SliverPadding changing padding'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
...
...
@@ -366,7 +394,7 @@ void main() {
),
),
);
expect
(
tester
.
renderObject
<
RenderSliverPadding
>(
find
.
byType
(
SliverPadding
)).
afterPadding
,
1.0
);
expect
(
tester
.
renderObject
<
RenderSliverPadding
>(
find
.
byType
(
SliverPadding
,
skipOffstage:
false
)).
afterPadding
,
1.0
);
});
testWidgets
(
'SliverPadding propagates geometry offset corrections'
,
(
WidgetTester
tester
)
async
{
...
...
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