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
6c0c6d30
Unverified
Commit
6c0c6d30
authored
Apr 22, 2021
by
Pedro Massango
Committed by
GitHub
Apr 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose padEnds on PageView widget (#78558)
parent
14759dc5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
page_view.dart
packages/flutter/lib/src/widgets/page_view.dart
+19
-0
page_view_test.dart
packages/flutter/test/widgets/page_view_test.dart
+25
-0
No files found.
packages/flutter/lib/src/widgets/page_view.dart
View file @
6c0c6d30
...
...
@@ -637,6 +637,7 @@ class PageView extends StatefulWidget {
this
.
restorationId
,
this
.
clipBehavior
=
Clip
.
hardEdge
,
this
.
scrollBehavior
,
this
.
padEnds
=
true
,
})
:
assert
(
allowImplicitScrolling
!=
null
),
assert
(
clipBehavior
!=
null
),
controller
=
controller
??
_defaultPageController
,
...
...
@@ -676,6 +677,7 @@ class PageView extends StatefulWidget {
this
.
restorationId
,
this
.
clipBehavior
=
Clip
.
hardEdge
,
this
.
scrollBehavior
,
this
.
padEnds
=
true
,
})
:
assert
(
allowImplicitScrolling
!=
null
),
assert
(
clipBehavior
!=
null
),
controller
=
controller
??
_defaultPageController
,
...
...
@@ -780,6 +782,7 @@ class PageView extends StatefulWidget {
this
.
restorationId
,
this
.
clipBehavior
=
Clip
.
hardEdge
,
this
.
scrollBehavior
,
this
.
padEnds
=
true
,
})
:
assert
(
childrenDelegate
!=
null
),
assert
(
allowImplicitScrolling
!=
null
),
assert
(
clipBehavior
!=
null
),
...
...
@@ -841,6 +844,10 @@ class PageView extends StatefulWidget {
final
ScrollPhysics
?
physics
;
/// Set to false to disable page snapping, useful for custom scroll behavior.
///
/// If the [padEnds] is false and [PageController.viewportFraction] < 1.0,
/// the page will snap to the beginning of the viewport; otherwise, the page
/// will snap to the center of the viewport.
final
bool
pageSnapping
;
/// Called whenever the page in the center of the viewport changes.
...
...
@@ -873,6 +880,17 @@ class PageView extends StatefulWidget {
/// modified by default to not apply a [Scrollbar].
final
ScrollBehavior
?
scrollBehavior
;
/// Whether to add padding to both ends of the list.
///
/// If this is set to true and [PageController.viewportFraction] < 1.0, padding will be added
/// such that the first and last child slivers will be in the center of
/// the viewport when scrolled all the way to the start or end, respectively.
///
/// If [PageController.viewportFraction] >= 1.0, this property has no effect.
///
/// This property defaults to true and must not be null.
final
bool
padEnds
;
@override
_PageViewState
createState
()
=>
_PageViewState
();
}
...
...
@@ -942,6 +960,7 @@ class _PageViewState extends State<PageView> {
SliverFillViewport
(
viewportFraction:
widget
.
controller
.
viewportFraction
,
delegate:
widget
.
childrenDelegate
,
padEnds:
widget
.
padEnds
,
),
],
);
...
...
packages/flutter/test/widgets/page_view_test.dart
View file @
6c0c6d30
...
...
@@ -985,4 +985,29 @@ void main() {
renderObject
.
paint
(
context
,
Offset
.
zero
);
expect
(
context
.
clipBehavior
,
equals
(
Clip
.
antiAlias
));
});
testWidgets
(
'PageView.padEnds tests'
,
(
WidgetTester
tester
)
async
{
Finder
viewportFinder
()
=>
find
.
byType
(
SliverFillViewport
,
skipOffstage:
false
);
// PageView() defaults to true.
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
PageView
(
children:
const
<
Widget
>[],
),
));
expect
(
tester
.
widget
<
SliverFillViewport
>(
viewportFinder
()).
padEnds
,
true
);
// PageView(padEnds: false) is propagated properly.
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
PageView
(
padEnds:
false
,
children:
const
<
Widget
>[],
),
));
expect
(
tester
.
widget
<
SliverFillViewport
>(
viewportFinder
()).
padEnds
,
false
);
});
}
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