seek method Null safety

Future<void> seek(
  1. Duration? position,
  2. {int? index}

Seeks to a particular position. If a composition of multiple AudioSources has been loaded, you may also specify index to seek to a particular item within that sequence. This method has no effect unless an audio source has been loaded.

A null position seeks to the head of a live stream.


Future<void> seek(final Duration? position, {int? index}) async {
  if (_disposed) return;
  _initialSeekValues = null;
  switch (processingState) {
    case ProcessingState.loading:
      _playbackEvent = _playbackEvent.copyWith(
        updatePosition: position,
      await (await _platform)
          .seek(SeekRequest(position: position, index: index));