mirror of
https://github.com/Livinglist/Hacki.git
synced 2025-08-06 18:24:42 +08:00
11 lines
274 B
Dart
11 lines
274 B
Dart
import 'dart:math';
|
|
|
|
extension ListExtension<T> on List<T> {
|
|
T? pickRandomly() {
|
|
if (isEmpty) return null;
|
|
final Random random = Random(DateTime.now().millisecondsSinceEpoch);
|
|
final int luckyNumber = random.nextInt(length);
|
|
return this[luckyNumber];
|
|
}
|
|
}
|