getTimeList static method
Generates a list of TimeOfDay objects at a specified interval.
durationInMinutes: The interval between each time slot.
startingHour: The hour (0-23) to start generating from.
endingHour: The hour (0-23) to stop generating at (exclusive).
startingMinute: The minute of the starting hour to begin from.
Implementation
static List<TimeOfDay> getTimeList({
int durationInMinutes = 30,
int startingHour = 6,
int endingHour = 23,
int startingMinute = 0,
}) {
List<TimeOfDay> result = [];
int length = (((endingHour - startingHour) * 60) / 30).floor();
customPrint('the length is $length');
for (int i = 0; i < length; i++) {
int hourBuffer =
((startingMinute + (durationInMinutes * i)) / 60).floor();
customPrint('dsfsk $durationInMinutes...$hourBuffer');
result.add(
TimeOfDay(
hour: startingHour + hourBuffer,
minute: (startingMinute + (durationInMinutes * i)) % 60,
),
);
}
return result;
}