Skip to content

Commit

Permalink
Merge pull request #286 from dumazy/customize_scrollphysics_monthview
Browse files Browse the repository at this point in the history
fix: Customize ScrollPhysics for MonthView
  • Loading branch information
PRBaraiya authored Nov 22, 2023
2 parents 2ef1d21 + 49b8936 commit 0ac0e44
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/src/month_view/month_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ class MonthView<T extends Object?> extends StatefulWidget {
/// Callback for the Header title
final HeaderTitleCallback? onHeaderTitleTap;

/// Defines scroll physics for a page of a month view.
///
/// This can be used to disable the vertical scroll of a page.
/// Default value is [ClampingScrollPhysics].
final ScrollPhysics pagePhysics;

/// Main [Widget] to display month view.
const MonthView({
Key? key,
Expand Down Expand Up @@ -170,6 +176,7 @@ class MonthView<T extends Object?> extends StatefulWidget {
this.headerStyle = const HeaderStyle(),
this.safeAreaOption = const SafeAreaOption(),
this.onHeaderTitleTap,
this.pagePhysics = const ClampingScrollPhysics(),
}) : assert(!(onHeaderTitleTap != null && headerBuilder != null),
"can't use [onHeaderTitleTap] & [headerBuilder] simultaneously"),
super(key: key);
Expand Down Expand Up @@ -349,6 +356,7 @@ class MonthViewState<T extends Object?> extends State<MonthView<T>> {
date: date,
showBorder: widget.showBorder,
startDay: widget.startDay,
physics: widget.pagePhysics,
),
);
}),
Expand Down Expand Up @@ -598,6 +606,7 @@ class _MonthPageBuilder<T> extends StatelessWidget {
final CellTapCallback<T>? onCellTap;
final DatePressCallback? onDateLongPress;
final WeekDays startDay;
final ScrollPhysics physics;

const _MonthPageBuilder({
Key? key,
Expand All @@ -613,6 +622,7 @@ class _MonthPageBuilder<T> extends StatelessWidget {
required this.onCellTap,
required this.onDateLongPress,
required this.startDay,
required this.physics,
}) : super(key: key);

@override
Expand All @@ -623,7 +633,7 @@ class _MonthPageBuilder<T> extends StatelessWidget {
height: height,
child: GridView.builder(
padding: EdgeInsets.zero,
physics: ClampingScrollPhysics(),
physics: physics,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7,
childAspectRatio: cellRatio,
Expand Down

0 comments on commit 0ac0e44

Please sign in to comment.