Skip to content

Commit

Permalink
Add the option of passing in a ScrollPhysics for the pages of the Mon…
Browse files Browse the repository at this point in the history
…thView

This allows passing in for example NeverScrollableScrollPhysics to avoid vertical scrolling
  • Loading branch information
dumazy committed Nov 8, 2023
1 parent 6ae1800 commit 4aeaf00
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 @@ -138,6 +138,12 @@ class MonthView<T extends Object?> extends StatefulWidget {
/// Option for SafeArea.
final SafeAreaOption safeAreaOption;

/// 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 @@ -166,6 +172,7 @@ class MonthView<T extends Object?> extends StatefulWidget {
this.weekDayStringBuilder,
this.headerStyle = const HeaderStyle(),
this.safeAreaOption = const SafeAreaOption(),
this.pagePhysics = const ClampingScrollPhysics(),
}) : super(key: key);

@override
Expand Down Expand Up @@ -343,6 +350,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 @@ -588,6 +596,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 @@ -603,6 +612,7 @@ class _MonthPageBuilder<T> extends StatelessWidget {
required this.onCellTap,
required this.onDateLongPress,
required this.startDay,
required this.physics,
}) : super(key: key);

@override
Expand All @@ -613,7 +623,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 4aeaf00

Please sign in to comment.