getRandomItem<T> function
Implementation
T? getRandomItem<T>(List<T> list) {
if (list.isEmpty) {
return null;
}
final random = Random();
final randomIndex = random.nextInt(list.length);
return list[randomIndex];
}
T? getRandomItem<T>(List<T> list) {
if (list.isEmpty) {
return null;
}
final random = Random();
final randomIndex = random.nextInt(list.length);
return list[randomIndex];
}