diff --git a/example/lib/widgets/month_view_widget.dart b/example/lib/widgets/month_view_widget.dart index bacec7eb..9bfb139e 100644 --- a/example/lib/widgets/month_view_widget.dart +++ b/example/lib/widgets/month_view_widget.dart @@ -18,6 +18,7 @@ class MonthViewWidget extends StatelessWidget { return MonthView( key: state, width: width, + showWeekends: false, hideDaysNotInMonth: false, onEventTap: (event, date) { Navigator.of(context).push( diff --git a/lib/src/month_view/month_view.dart b/lib/src/month_view/month_view.dart index 51690910..b10abd55 100644 --- a/lib/src/month_view/month_view.dart +++ b/lib/src/month_view/month_view.dart @@ -64,6 +64,11 @@ class MonthView extends StatefulWidget { /// This method will be called when user double taps on event tile. final TileTapCallback? onEventDoubleTap; + /// Show weekends or not + /// + /// Default value is true. + final bool showWeekends; + /// Builds the name of the weeks. /// /// Used default week builder if null. @@ -184,6 +189,7 @@ class MonthView extends StatefulWidget { this.maxMonth, this.controller, this.initialMonth, + this.showWeekends = true, this.borderSize = 1, this.useAvailableVerticalSpace = false, this.cellAspectRatio = 0.55, @@ -352,7 +358,7 @@ class MonthViewState extends State> { width: _width, child: Row( children: List.generate( - 7, + widget.showWeekends ? 7 : 5, (index) => Expanded( child: SizedBox( width: _cellWidth, @@ -391,6 +397,7 @@ class MonthViewState extends State> { startDay: widget.startDay, physics: widget.pagePhysics, hideDaysNotInMonth: widget.hideDaysNotInMonth, + dayCount: widget.showWeekends ? 7 : 5, ), ); }), @@ -663,6 +670,7 @@ class _MonthPageBuilder extends StatelessWidget { final WeekDays startDay; final ScrollPhysics physics; final bool hideDaysNotInMonth; + final int dayCount; const _MonthPageBuilder({ Key? key, @@ -680,6 +688,7 @@ class _MonthPageBuilder extends StatelessWidget { required this.startDay, required this.physics, required this.hideDaysNotInMonth, + required this.dayCount, }) : super(key: key); @override @@ -692,7 +701,7 @@ class _MonthPageBuilder extends StatelessWidget { padding: EdgeInsets.zero, physics: physics, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 7, + crossAxisCount: dayCount, childAspectRatio: cellRatio, ), itemCount: 42,