From 4aeaf00d3c5d212c99562f40a94e28a93752c8e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9=20Dumazy?= Date: Wed, 8 Nov 2023 20:18:42 +0100 Subject: [PATCH] Add the option of passing in a ScrollPhysics for the pages of the MonthView This allows passing in for example NeverScrollableScrollPhysics to avoid vertical scrolling --- lib/src/month_view/month_view.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/src/month_view/month_view.dart b/lib/src/month_view/month_view.dart index 11a794bd..b19f7851 100644 --- a/lib/src/month_view/month_view.dart +++ b/lib/src/month_view/month_view.dart @@ -138,6 +138,12 @@ class MonthView 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, @@ -166,6 +172,7 @@ class MonthView extends StatefulWidget { this.weekDayStringBuilder, this.headerStyle = const HeaderStyle(), this.safeAreaOption = const SafeAreaOption(), + this.pagePhysics = const ClampingScrollPhysics(), }) : super(key: key); @override @@ -343,6 +350,7 @@ class MonthViewState extends State> { date: date, showBorder: widget.showBorder, startDay: widget.startDay, + physics: widget.pagePhysics, ), ); }), @@ -588,6 +596,7 @@ class _MonthPageBuilder extends StatelessWidget { final CellTapCallback? onCellTap; final DatePressCallback? onDateLongPress; final WeekDays startDay; + final ScrollPhysics physics; const _MonthPageBuilder({ Key? key, @@ -603,6 +612,7 @@ class _MonthPageBuilder extends StatelessWidget { required this.onCellTap, required this.onDateLongPress, required this.startDay, + required this.physics, }) : super(key: key); @override @@ -613,7 +623,7 @@ class _MonthPageBuilder extends StatelessWidget { height: height, child: GridView.builder( padding: EdgeInsets.zero, - physics: ClampingScrollPhysics(), + physics: physics, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 7, childAspectRatio: cellRatio,