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
37ebe3d8
Unverified
Commit
37ebe3d8
authored
Oct 13, 2020
by
Jonah Williams
Committed by
GitHub
Oct 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "prevent pageView scrolling when calling ensureVisible (#67988)" (#68036)
This reverts commit
62cf4dbf
.
parent
a57f45e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
73 deletions
+11
-73
page_view.dart
packages/flutter/lib/src/widgets/page_view.dart
+11
-3
scrollable_test.dart
packages/flutter/test/widgets/scrollable_test.dart
+0
-70
No files found.
packages/flutter/lib/src/widgets/page_view.dart
View file @
37ebe3d8
...
...
@@ -341,9 +341,17 @@ class _PagePosition extends ScrollPositionWithSingleContext implements PageMetri
RenderObject
?
targetRenderObject
,
})
{
// Since the _PagePosition is intended to cover the available space within
// its viewport, stop trying to any scroll, otherwise, could end up changing
// which page is visible and moving the render object out of the viewport.
return
Future
<
void
>.
value
();
// its viewport, stop trying to move the target render object to the center
// - otherwise, could end up changing which page is visible and moving the
// targetRenderObject out of the viewport.
return
super
.
ensureVisible
(
object
,
alignment:
alignment
,
duration:
duration
,
curve:
curve
,
alignmentPolicy:
alignmentPolicy
,
targetRenderObject:
null
,
);
}
@override
...
...
packages/flutter/test/widgets/scrollable_test.dart
View file @
37ebe3d8
...
...
@@ -1006,76 +1006,6 @@ void main() {
expect
(
targetMidRightPage1
,
findsOneWidget
);
expect
(
targetMidLeftPage1
,
findsOneWidget
);
});
testWidgets
(
'ensureVisible does not move PageViews when there are objects between pageView and target object'
,
(
WidgetTester
tester
)
async
{
final
PageController
controller
=
PageController
();
int
count
=
0
;
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
PageView
(
controller:
controller
,
children:
List
<
Widget
>.
generate
(
3
,
(
int
index
)
{
return
Row
(
children:
<
Widget
>[
Container
(
width:
400
,
color:
Colors
.
red
,
),
Expanded
(
child:
Container
(
color:
Colors
.
green
,
width:
double
.
infinity
,
height:
50
,
child:
SingleChildScrollView
(
scrollDirection:
Axis
.
horizontal
,
child:
Container
(
key:
Key
(
index
.
toString
()),
color:
Colors
.
yellow
,
height:
50
,
width:
200
,
),
),
),
)
],
);
}),
),
),
);
controller
.
position
.
addListener
(()
{
count
++;
});
final
Finder
targetOfPage0
=
find
.
byKey
(
const
Key
(
'0'
));
final
Finder
targetOfPage1
=
find
.
byKey
(
const
Key
(
'1'
));
expect
(
targetOfPage0
,
findsOneWidget
);
expect
(
targetOfPage1
,
findsNothing
);
// `ensureVisible` should not trigger any scrolling or page changing of pageView.
await
tester
.
ensureVisible
(
targetOfPage0
);
await
tester
.
pumpAndSettle
();
expect
(
count
,
0
);
expect
(
targetOfPage0
,
findsOneWidget
);
expect
(
targetOfPage1
,
findsNothing
);
controller
.
jumpToPage
(
1
);
await
tester
.
pumpAndSettle
();
expect
(
count
,
1
);
// Trigger by `controller.jumpToPage(1)`
expect
(
targetOfPage0
,
findsNothing
);
expect
(
targetOfPage1
,
findsOneWidget
);
await
tester
.
ensureVisible
(
targetOfPage1
);
await
tester
.
pumpAndSettle
();
expect
(
count
,
1
);
expect
(
targetOfPage0
,
findsNothing
);
expect
(
targetOfPage1
,
findsOneWidget
);
});
}
// ignore: must_be_immutable
...
...
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