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.

Implementation

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