stopRecording method
Stop recording
Implementation
Future<void> stopRecording() async {
if (!_isRecording) return;
try {
// Cancel stream subscription
await _audioStreamSubscription?.cancel();
_audioStreamSubscription = null;
// Stop the recorder
await _recorder.stop();
_isRecording = false;
_audioLevel = 0.0;
_onAudioData = null;
_recordingStateController.add(false);
_audioLevelController.add(0.0);
_logger.info('Recording stopped');
} catch (e) {
_logger.error('Error stopping recording: $e');
}
}