shuffle method

  1. @override
void shuffle({
  1. int? initialIndex,
})
override

Shuffles the indices. If the current item in the player falls within the ConcatenatingAudioSource being shuffled, initialIndex will point to that item. Subclasses may use this information as a hint, for example, to make initialIndex the first item in the shuffle order.

Implementation

@override
void shuffle({int? initialIndex}) {
  assert(initialIndex == null || indices.contains(initialIndex));
  if (indices.length <= 1) return;
  indices.shuffle(_random);
  if (initialIndex == null) return;

  const initialPos = 0;
  final swapPos = indices.indexOf(initialIndex);
  // Swap the indices at initialPos and swapPos.
  final swapIndex = indices[initialPos];
  indices[initialPos] = initialIndex;
  indices[swapPos] = swapIndex;
}