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
8e58c51d
Unverified
Commit
8e58c51d
authored
Jul 23, 2020
by
Michael Goderbauer
Committed by
GitHub
Jul 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update viewport dimensions when scrollDirection changes (#61973)
parent
4b4287ba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
10 deletions
+52
-10
viewport.dart
packages/flutter/lib/src/rendering/viewport.dart
+11
-10
page_view.dart
packages/flutter/lib/src/widgets/page_view.dart
+3
-0
list_view_test.dart
packages/flutter/test/widgets/list_view_test.dart
+38
-0
No files found.
packages/flutter/lib/src/rendering/viewport.dart
View file @
8e58c51d
...
...
@@ -1321,16 +1321,6 @@ class RenderViewport extends RenderViewportBase<SliverPhysicalContainerParentDat
return
true
;
}());
size
=
constraints
.
biggest
;
// We ignore the return value of applyViewportDimension below because we are
// going to go through performLayout next regardless.
switch
(
axis
)
{
case
Axis
.
vertical
:
offset
.
applyViewportDimension
(
size
.
height
);
break
;
case
Axis
.
horizontal
:
offset
.
applyViewportDimension
(
size
.
width
);
break
;
}
}
static
const
int
_maxLayoutCycles
=
10
;
...
...
@@ -1342,6 +1332,17 @@ class RenderViewport extends RenderViewportBase<SliverPhysicalContainerParentDat
@override
void
performLayout
()
{
// Ignore the return value of applyViewportDimension because we are
// doing a layout regardless.
switch
(
axis
)
{
case
Axis
.
vertical
:
offset
.
applyViewportDimension
(
size
.
height
);
break
;
case
Axis
.
horizontal
:
offset
.
applyViewportDimension
(
size
.
width
);
break
;
}
if
(
center
==
null
)
{
assert
(
firstChild
==
null
);
_minScrollExtent
=
0.0
;
...
...
packages/flutter/lib/src/widgets/page_view.dart
View file @
8e58c51d
...
...
@@ -395,6 +395,9 @@ class _PagePosition extends ScrollPositionWithSingleContext implements PageMetri
@override
bool
applyViewportDimension
(
double
viewportDimension
)
{
final
double
oldViewportDimensions
=
this
.
viewportDimension
;
if
(
viewportDimension
==
oldViewportDimensions
)
{
return
true
;
}
final
bool
result
=
super
.
applyViewportDimension
(
viewportDimension
);
final
double
oldPixels
=
pixels
;
final
double
page
=
(
oldPixels
==
null
||
oldViewportDimensions
==
0.0
)
?
_pageToUseOnStartup
:
getPageFromPixels
(
oldPixels
,
oldViewportDimensions
);
...
...
packages/flutter/test/widgets/list_view_test.dart
View file @
8e58c51d
...
...
@@ -537,4 +537,42 @@ void main() {
));
handle
.
dispose
();
});
testWidgets
(
'Updates viewport dimensions when scroll direction changes'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/43380.
final
ScrollController
controller
=
ScrollController
();
Widget
buildListView
({
@required
Axis
scrollDirection
})
{
assert
(
scrollDirection
!=
null
);
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
Container
(
height:
200.0
,
width:
100.0
,
child:
ListView
(
controller:
controller
,
scrollDirection:
scrollDirection
,
itemExtent:
50.0
,
children:
<
Widget
>[
Container
(
height:
50.0
,
width:
50.0
,
),
],
),
),
),
);
}
await
tester
.
pumpWidget
(
buildListView
(
scrollDirection:
Axis
.
horizontal
));
expect
(
controller
.
position
.
viewportDimension
,
100.0
);
await
tester
.
pumpWidget
(
buildListView
(
scrollDirection:
Axis
.
vertical
));
expect
(
controller
.
position
.
viewportDimension
,
200.0
);
await
tester
.
pumpWidget
(
buildListView
(
scrollDirection:
Axis
.
horizontal
));
expect
(
controller
.
position
.
viewportDimension
,
100.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