Iterable<T> takeRandom(int n) sync* { Set<int> indices = {}; while (indices.length < n) { indices.add(math.Random().nextInt(length)); } for (var i in indices) { yield this[i]; } }