getSlotTimesListMap method
Implementation
Map<String, List<DateTime>> getSlotTimesListMap({
required List<DateTime> listDates,
}) {
final Map<String, List<DateTime>> slotTimes = {
"morning": [],
"afternoon": [],
"evening": [],
"night": []
};
for (final element in listDates) {
/// get day part of time
final DayParts? dayPart = getDayPartOfTime(time: element);
if (dayPart != null) {
/// get day part name of time
final String dayPartName = getDayPartName(dayPart: dayPart);
/// full map of slot
final List<DateTime> list = [element];
if (slotTimes[dayPartName] != null &&
slotTimes[dayPartName]!.isNotEmpty) {
list.addAll(slotTimes[dayPartName]!);
}
list.sort();
slotTimes[dayPartName] = list;
}
}
return slotTimes;
}