Skip to content

Instantly share code, notes, and snippets.

@snapsl
Created March 20, 2024 17:46
Show Gist options
  • Save snapsl/6af31a539c9128e2b40face2b99bbad2 to your computer and use it in GitHub Desktop.
Save snapsl/6af31a539c9128e2b40face2b99bbad2 to your computer and use it in GitHub Desktop.
import 'dart:math' as math;
extension RandomListItem<T> on List<T> {
static final _rand = math.Random();
/// picks a random item from the list.
T randomItem() => this[_rand.nextInt(length)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment