getAllMonthsIn1Year static method
!latest removed #1
If selectedYear
is 2021 then this function will return all the dates of months in 2021 in the form of List<Map<String, List<DateTime>>>
Implementation
// ///This function will return all the DateTime in one year [yearDate]
// static List<DateTime> getAllDatesIn1Year(
// {required DateTime yearDate, required List<DateTime> allDates}) {
// List<DateTime> dates =
// allDates.where((element) => element.year == yearDate.year).toList();
// return dates;
// }
///If [selectedYear] is 2021 then this function will return all the dates of months in 2021 in the form of [List<Map<String, List<DateTime>>>]
static List<Map<String, List<DateTime>>> getAllMonthsIn1Year(
{required DateTime selectedYear}) {
///returns all the dates in a year
///!latest removed #1
// List<DateTime> _listOfDatesInYear = getAllDatesIn1Year(
// yearDate: selectedYear,
// allDates: allDates,
// );
///!replaced
List<DateTime> _listOfDatesInYear = DateUtilsCB.getAllDaysInBetweenYears(
startDate: DateTime(selectedYear.year),
endDate:
DateTime(selectedYear.year + 1).subtract(const Duration(days: 1)));
///genrating Dates in each months as List<DateTime>
List<DateTime> _listOfJan = _listOfDatesInYear
.where((element) => element.month == DateTime.january)
.toList();
List<DateTime> _listOfFeb = _listOfDatesInYear
.where((element) => element.month == DateTime.february)
.toList();
List<DateTime> _listOfMarch = _listOfDatesInYear
.where((element) => element.month == DateTime.march)
.toList();
List<DateTime> _listOfApril = _listOfDatesInYear
.where((element) => element.month == DateTime.april)
.toList();
List<DateTime> _listOfMay = _listOfDatesInYear
.where((element) => element.month == DateTime.may)
.toList();
List<DateTime> _listOfJune = _listOfDatesInYear
.where((element) => element.month == DateTime.june)
.toList();
List<DateTime> _listOfJuly = _listOfDatesInYear
.where((element) => element.month == DateTime.july)
.toList();
List<DateTime> _listOfAugust = _listOfDatesInYear
.where((element) => element.month == DateTime.august)
.toList();
List<DateTime> _listOfSept = _listOfDatesInYear
.where((element) => element.month == DateTime.september)
.toList();
List<DateTime> _listOfOct = _listOfDatesInYear
.where((element) => element.month == DateTime.october)
.toList();
List<DateTime> _listOfNov = _listOfDatesInYear
.where((element) => element.month == DateTime.november)
.toList();
List<DateTime> _listOfDec = _listOfDatesInYear
.where((element) => element.month == DateTime.december)
.toList();
List<Map<String, List<DateTime>>> _months = [
{'Jan': _listOfJan},
{'Feb': _listOfFeb},
{'March': _listOfMarch},
{'April': _listOfApril},
{'May': _listOfMay},
{'June': _listOfJune},
{'July': _listOfJuly},
{'August': _listOfAugust},
{'Sept': _listOfSept},
{'Oct': _listOfOct},
{'Nov': _listOfNov},
{'Dec': _listOfDec},
];
return _months;
}