Skip to content

Commit

Permalink
feat: Add scrollDirection and scrollBehavior properties to Expandable…
Browse files Browse the repository at this point in the history
…PageView
  • Loading branch information
Limbou committed Sep 19, 2021
1 parent 22fdcca commit dab7048
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.6"
version: "1.0.7"
fake_async:
dependency: transitive
description:
Expand Down
26 changes: 24 additions & 2 deletions lib/expandable_page_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ class ExpandablePageView extends StatefulWidget {
/// reversed - "expand and shrink" - effect.
final double estimatedPageSize;

///A ScrollBehavior that will be applied to this widget individually.
//
// Defaults to null, wherein the inherited ScrollBehavior is copied and modified to alter the viewport decoration, like Scrollbars.
//
// ScrollBehaviors also provide ScrollPhysics. If an explicit ScrollPhysics is provided in physics, it will take precedence, followed by scrollBehavior, and then the inherited ancestor ScrollBehavior.
//
// The ScrollBehavior of the inherited ScrollConfiguration will be modified by default to not apply a Scrollbar.
final ScrollBehavior? scrollBehavior;

///The axis along which the page view scrolls.
//
// Defaults to Axis.horizontal.
final Axis scrollDirection;

ExpandablePageView({
this.children,
this.controller,
Expand All @@ -117,6 +131,8 @@ class ExpandablePageView extends StatefulWidget {
this.animateFirstPage = false,
this.estimatedPageSize = 0.0,
this.alignment = Alignment.topCenter,
this.scrollBehavior,
this.scrollDirection = Axis.horizontal,
Key? key,
}) : assert(estimatedPageSize >= 0.0),
itemBuilder = null,
Expand All @@ -140,6 +156,8 @@ class ExpandablePageView extends StatefulWidget {
this.animateFirstPage = false,
this.estimatedPageSize = 0.0,
this.alignment = Alignment.topCenter,
this.scrollBehavior,
this.scrollDirection = Axis.horizontal,
Key? key,
}) : assert(estimatedPageSize >= 0.0),
children = null,
Expand Down Expand Up @@ -186,11 +204,11 @@ class _ExpandablePageViewState extends State<ExpandablePageView> {
if (_shouldReinitializeHeights(oldWidget)) {
final currentPageHeight = _heights[_currentPage];
_heights = _prepareHeights();

if (_currentPage >= _heights.length) {
_currentPage--;
widget.onPageChanged?.call(_currentPage);

if (_previousPage > 0) {
_previousPage--;
}
Expand Down Expand Up @@ -249,6 +267,8 @@ class _ExpandablePageViewState extends State<ExpandablePageView> {
allowImplicitScrolling: widget.allowImplicitScrolling,
restorationId: widget.restorationId,
clipBehavior: widget.clipBehavior,
scrollBehavior: widget.scrollBehavior,
scrollDirection: widget.scrollDirection,
);
}
return PageView(
Expand All @@ -263,6 +283,8 @@ class _ExpandablePageViewState extends State<ExpandablePageView> {
allowImplicitScrolling: widget.allowImplicitScrolling,
restorationId: widget.restorationId,
clipBehavior: widget.clipBehavior,
scrollBehavior: widget.scrollBehavior,
scrollDirection: widget.scrollDirection,
);
}

Expand Down

0 comments on commit dab7048

Please sign in to comment.