From 10b77e2bb58ea5127f96eb969d5291273eabab01 Mon Sep 17 00:00:00 2001 From: Eugene Dina Date: Wed, 23 Mar 2022 16:56:58 -0600 Subject: [PATCH 1/2] fix for shifted day when viewing expanded month and startOnMonday = false --- lib/flutter_neat_and_clean_calendar.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/flutter_neat_and_clean_calendar.dart b/lib/flutter_neat_and_clean_calendar.dart index cc43630..8450209 100644 --- a/lib/flutter_neat_and_clean_calendar.dart +++ b/lib/flutter_neat_and_clean_calendar.dart @@ -949,7 +949,8 @@ class _CalendarState extends State { List _daysInMonth(DateTime month) { var first = Utils.firstDayOfMonth(month); var daysBefore = first.weekday; - var firstToDisplay = first.subtract(new Duration(days: daysBefore - 1)); + var firstToDisplay = first.subtract( + new Duration(days: daysBefore - (widget.startOnMonday ? 1 : 0))); var last = Utils.lastDayOfMonth(month); var daysAfter = 7 - last.weekday; @@ -961,7 +962,8 @@ class _CalendarState extends State { // Adding an extra day necessary. Otherwise the week with days in next month // would always end on Saturdays. - var lastToDisplay = last.add(new Duration(days: daysAfter + 1)); + var lastToDisplay = last.add( + new Duration(days: daysAfter + (widget.startOnMonday ? 1 : 0))); return Utils.daysInRange(firstToDisplay, lastToDisplay).toList(); } } From 836d8472176cf38fd0e92a86ca91d75cbecbfe84 Mon Sep 17 00:00:00 2001 From: Eugene Dina Date: Thu, 24 Mar 2022 07:27:36 -0600 Subject: [PATCH 2/2] Updated code comments --- lib/flutter_neat_and_clean_calendar.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/flutter_neat_and_clean_calendar.dart b/lib/flutter_neat_and_clean_calendar.dart index 8450209..9ffc964 100644 --- a/lib/flutter_neat_and_clean_calendar.dart +++ b/lib/flutter_neat_and_clean_calendar.dart @@ -960,8 +960,8 @@ class _CalendarState extends State { daysAfter = 7; } - // Adding an extra day necessary. Otherwise the week with days in next month - // would always end on Saturdays. + // Adding an extra day necessary (if week starts on Monday). + // Otherwise the week with days in next month would always end on Saturdays. var lastToDisplay = last.add( new Duration(days: daysAfter + (widget.startOnMonday ? 1 : 0))); return Utils.daysInRange(firstToDisplay, lastToDisplay).toList();