From 885a67d3cb32438a283e27df74a729f7737f35b4 Mon Sep 17 00:00:00 2001 From: Parth Baraiya Date: Thu, 2 Jun 2022 16:46:18 +0530 Subject: [PATCH] :checkered_flag: provide start day while navigating to next page in week view. (#75) --- lib/src/month_view/month_view.dart | 4 +--- lib/src/week_view/week_view.dart | 8 +++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/src/month_view/month_view.dart b/lib/src/month_view/month_view.dart index 3a080aa8..defe5a21 100644 --- a/lib/src/month_view/month_view.dart +++ b/lib/src/month_view/month_view.dart @@ -400,7 +400,6 @@ class MonthViewState extends State> { _currentDate = DateTime( _currentDate.year, _currentDate.month + (value - _currentIndex), - _currentDate.day, ); _currentIndex = value; }); @@ -517,8 +516,7 @@ class MonthViewState extends State> { } /// Returns the current visible date in month view. - DateTime get currentDate => - DateTime(_currentDate.year, _currentDate.month, _currentDate.day); + DateTime get currentDate => DateTime(_currentDate.year, _currentDate.month); } /// A single month page. diff --git a/lib/src/week_view/week_view.dart b/lib/src/week_view/week_view.dart index 3225a1e2..78912306 100644 --- a/lib/src/week_view/week_view.dart +++ b/lib/src/week_view/week_view.dart @@ -474,7 +474,8 @@ class WeekViewState extends State> { "Provided minimum date: $_minDate, maximum date: $_maxDate", ); - _totalWeeks = _minDate.getWeekDifference(_maxDate) + 1; + _totalWeeks = + _minDate.getWeekDifference(_maxDate, start: widget.startDay) + 1; } /// Default builder for week line. @@ -621,7 +622,8 @@ class WeekViewState extends State> { if (week.isBefore(_minDate) || week.isAfter(_maxDate)) { throw "Invalid date selected."; } - _pageController.jumpToPage(_minDate.getWeekDifference(week)); + _pageController + .jumpToPage(_minDate.getWeekDifference(week, start: widget.startDay)); } /// Animate to page which gives day calendar for [week]. @@ -635,7 +637,7 @@ class WeekViewState extends State> { throw "Invalid date selected."; } await _pageController.animateToPage( - _minDate.getWeekDifference(week), + _minDate.getWeekDifference(week, start: widget.startDay), duration: duration ?? widget.pageTransitionDuration, curve: curve ?? widget.pageTransitionCurve, );