insert method

bool insert(
  1. int index,
  2. AudioSource source
)

Inserts a source at the specified index

Returns true if successful, false if the index is out of bounds

Implementation

bool insert(int index, AudioSource source) {
  if (index < 0 || index > _sources.length) {
    return false;
  }

  final newSources = List<AudioSource>.from(_sources);
  newSources.insert(index, source);

  // Adjust current index if necessary
  if (index <= _currentIndex) {
    _currentIndex++;
  }

  _updateSources(newSources);
  return true;
}