Filter List in Dart

Use Random from dart:math:

import 'dart:math';

main() {
  var random = Random();
  for (var i = 0; i < 10; i++) {

.nextInt(k) generates a random integer number in [0, k), i.e. from 0 to k-1 included.

Subscribe to My Newsletter

The latest programming-related news, articles and resources - sent to your inbox monthly. Unsubscribe anytime.