Change magic number 7 for DateTime.daysPerWeek

This commit is contained in:
Bart Ribbers 2022-11-18 13:28:18 +01:00
parent 2fe07a9747
commit 900b88a442

View file

@ -38,12 +38,12 @@ class DatePicker extends StatelessWidget {
int addedIndex = 0; int addedIndex = 0;
if (daysToSkip >= 7) { if (daysToSkip >= DateTime.daysPerWeek) {
addedIndex = 7; addedIndex = DateTime.daysPerWeek;
} }
int length = DateTime(date.year, date.month).daysInMonth() + daysToSkip; int length = DateTime(date.year, date.month).daysInMonth() + daysToSkip;
int daysToAdd = 7 - length % 7; int daysToAdd = DateTime.daysPerWeek - length % DateTime.daysPerWeek;
return Column( return Column(
children: [ children: [
if (showWeekDays) ...[ if (showWeekDays) ...[
@ -72,7 +72,7 @@ class DatePicker extends StatelessWidget {
Expanded( Expanded(
child: GridView.count( child: GridView.count(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
crossAxisCount: 7, crossAxisCount: DateTime.daysPerWeek,
children: List.generate( children: List.generate(
length + daysToAdd, length + daysToAdd,
(index) { (index) {