randomTime property
TimeOfDay
get
randomTime
Get a random time between startTime and endTime
Implementation
TimeOfDay get randomTime {
TimeOfDay randomTime = const TimeOfDay();
do {
int randomHour = startTime.hour +
((endTime.hour - startTime.hour == 0)
? 0
: Random().nextInt(endTime.hour - startTime.hour));
int randomMinutes = Random().nextInt(60);
randomTime = TimeOfDay(hour: randomHour, minute: randomMinutes);
} while (!(randomTime.isAfter(startTime) && randomTime.isBefore(endTime)));
return randomTime;
}