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
48d5fcab
Unverified
Commit
48d5fcab
authored
Feb 11, 2020
by
LongCatIsLooong
Committed by
GitHub
Feb 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
evict _SliverFractionalPadding cache on constraint change (#50523)
parent
f15c887c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
1 deletion
+47
-1
sliver_fill.dart
packages/flutter/lib/src/widgets/sliver_fill.dart
+5
-1
page_view_test.dart
packages/flutter/test/widgets/page_view_test.dart
+42
-0
No files found.
packages/flutter/lib/src/widgets/sliver_fill.dart
View file @
48d5fcab
...
...
@@ -122,6 +122,8 @@ class _RenderSliverFractionalPadding extends RenderSliverEdgeInsetsPadding {
assert
(
viewportFraction
>=
0
),
_viewportFraction
=
viewportFraction
;
SliverConstraints
_lastResolvedConstraints
;
double
get
viewportFraction
=>
_viewportFraction
;
double
_viewportFraction
;
set
viewportFraction
(
double
newValue
)
{
...
...
@@ -142,10 +144,12 @@ class _RenderSliverFractionalPadding extends RenderSliverEdgeInsetsPadding {
}
void
_resolve
()
{
if
(
_resolvedPadding
!=
null
)
if
(
_resolvedPadding
!=
null
&&
_lastResolvedConstraints
==
constraints
)
return
;
assert
(
constraints
.
axis
!=
null
);
final
double
paddingValue
=
constraints
.
viewportMainAxisExtent
*
viewportFraction
;
_lastResolvedConstraints
=
constraints
;
switch
(
constraints
.
axis
)
{
case
Axis
.
horizontal
:
_resolvedPadding
=
EdgeInsets
.
symmetric
(
horizontal:
paddingValue
);
...
...
packages/flutter/test/widgets/page_view_test.dart
View file @
48d5fcab
...
...
@@ -682,6 +682,48 @@ void main() {
}
});
testWidgets
(
'the current item remains centered on constraint change'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/50505.
final
PageController
controller
=
PageController
(
initialPage:
kStates
.
length
-
1
,
viewportFraction:
0.5
,
);
Widget
build
(
Size
size
)
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
.
fromSize
(
size:
size
,
child:
PageView
(
children:
kStates
.
map
<
Widget
>((
String
state
)
=>
Text
(
state
)).
toList
(),
controller:
controller
,
onPageChanged:
(
int
page
)
{
},
),
),
),
);
}
// Verifies that the last item is centered on screen.
void
verifyCentered
()
{
expect
(
tester
.
getCenter
(
find
.
text
(
kStates
.
last
)),
offsetMoreOrLessEquals
(
const
Offset
(
400
,
300
)),
);
}
await
tester
.
pumpWidget
(
build
(
const
Size
(
300
,
300
)));
await
tester
.
pumpAndSettle
();
verifyCentered
();
await
tester
.
pumpWidget
(
build
(
const
Size
(
200
,
300
)));
await
tester
.
pumpAndSettle
();
verifyCentered
();
});
testWidgets
(
'PageView does not report page changed on overscroll'
,
(
WidgetTester
tester
)
async
{
final
PageController
controller
=
PageController
(
initialPage:
kStates
.
length
-
1
,
...
...
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