takeRandom method

E? takeRandom({
  1. int? seed,
})

Removes a random element of this and returns it.

Returns null if this is empty.

If seed is provided, will be used as the random seed for determining which element to select. (See math.Random.)

Implementation

E? takeRandom({int? seed}) => this.isEmpty
    ? null
    : this.removeAt(math.Random(seed).nextInt(this.length));