stop method

Future<String?> stop([
  1. bool callReset = true
])

Use this stop recording. Resources are freed after calling this and file is saved. Returns path where file is saved.

Also clears waveform and resets to initial state. This behaviour can be changed, pass false and it will not clear waves.

Implementation

Future<String?> stop([bool callReset = true]) async {
  if (_recorderState == RecorderState.recording ||
      _recorderState == RecorderState.paused) {
    final path = await AudioWaveformsInterface.instance.stop();
    if (path != null) {
      _isRecording = false;
      _timer?.cancel();
      _recorderState = RecorderState.stopped;
      if (callReset) reset();
      return path;
    } else {
      throw "Failed stop recording";
    }
  }

  notifyListeners();
  return null;
}