'pause feature in flutter sound package

i would like to implement in my code a pause feature in my projet. i use flutter sound package but i have a same error. i can play and stop.

  Future _record() async {
    await _audioRecorder!.openAudioSession();
    await _audioRecorder!.startRecorder(
      toFile: pathToSaveAudio,
      codec: Codec.pcm16WAV,
    );
  }

  Future _pauseRecord() async {
    await _audioRecorder!.pauseRecorder();
  }

  Future _stop() async {
    _audioRecorder!.closeAudioSession();
    return await _audioRecorder!.stopRecorder();
  }

  Future toogleRecording() async {
    if (!_audioRecorder!.isRecording) {
      await _record();
    } else {
      await _pauseRecord(); //this line doesn't work il my case
    }
  }

i have some exception whe i try to excécute pause feature



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source